Post to Facebook & Twitter

Hi all,

I’m trying to build an application or script that will post a status update to Facebook & Twitter when a user registers on my site. To clarify the steps I’m trying to reproduce:

  1. User visits my site and chooses to register
  2. User fills in the registration form and is given the option to “Share” the news with their friends on Facebook & Twitter
  3. User agrees and an “Overlay” box appears with a text field already pre-filled with some wording for their status update (which they can edit if they want to)
  4. User submits the update and it is sent to Facebook & Twitter.
  5. Overlay box closes and registration form can be submitted as usual.

The problem I am facing is that I have absolutely NO experience developing Facebook & Twitter Applications. I wondered if there was already an application or plugin out there that could handle this kind of functionality… I’m sure it’s a popular requirement. I’ve searched Google all night but have not found anything that makes sense to me.

Is it even possible to post to both profiles with one update… How would I get the users to login if they aren’t already (or if they are logged in to one but not the other… or if they only have one or the other…)

I guess I’m just looking for some advice at this stage… maybe a friendly App developer who could point me in the right direction - I’m a very quick learner, I just need to know where to look.

Both platforms have widgets [as well as advanced APIs] that will let you launch posts but it’s not quite as simple as having a user register and just pushing out posts.

In the name of protecting users from app spam, both require the user to make the post themselves. You can launch a request but it’s still up to the user to click to share it. And of course each is independent so you’d have to let the user select one after the other.

For the long term, users can “connect” in which will give you some additional rights to post elements on their behalf. Of course doing this also requires an external jump via a popup window which Facebook and Twitter host that explains the permissions you are asking for. Of course not all users will agree to this, especially if you ask for higher impact rights.

Ultimately trying to force a share is a recipe for disaster. People will scream, yell and not return. Instead why not make sharing a very easy experience but also useful? Two big links on the confirmation page and a value statement… Bring your friends in to blah, blah… It’s by no means guaranteed but it’s how the system works best.

And remember, not everyone is on both platforms either (especially true for twitter).

Hiya Ted,

Firstly - Thank you for your reply.

I did think myself after I posted that it would probably be a long shot to try and implement what I suppose could be seen as “Forced Sharing.” I know now that it would involve developing an application in both Facebook & Twitter to post on the user’s behalf and that the user would need to give the application permission still.

Here is what I’m trying to achieve.

We are starting a new website and on this website we are giving users the chance to buy premium membership. For the first users to register though (number yet to be determined) we will be giving free memberships as a thank you but a condition of receiving the free membership is sharing the site to your FB/Twitter friends. So we want to include the sharing options in the registration / confirmation but we need to be able to track who has and who hasn’t clicked.

So I thought about this:

https://twitter.com/about/resources/tweetbutton allows you to customtize a tweet that people can send from your page, which would be perfect as I could include our @TwitterID in the tweet so I would receive the mention - Although I still think I need to find a way to record in the database somewhere that this person had clicked on the link because we may be giving away over 1,000 memberships and I don’t fancy scrolling through 1,000 tweets trying to figure out who’s account they came from on my site.

Facebook also offer a “Social Plugin” in the form of a “Like/Recommend” button which will share our site… Again, perfect - but I still need to be able to track who has clicked it.

So my question now is this:

Can I put these two buttons/links on my registration form and include some PHP that will track whether or not they have been clicked and record it somewhere in a database along with the username that was registered?

I also need to include an option to “opt out” so those who don’t want to share can say so and I need to wrap the two options in an element that means you have to choose either to share or opt out before you can submit the registration.

Am I making sense? Is this possible?

Ethically and practically forcing a share is really never a good idea. You lose more people than you gain, people who do share delete the comment, and those that remain are done without any real interest. A share for the sake of a reward is not advocacy. As such social sites forbid the forcing of a share… making it an option is smart all around.

As for your system, here’s what I’d suggest.

Depending on how you do the sharing, each method has a different way of tracking the result. Using Facebook’s JavaScript SDK publishStream() function you can trigger back which, using ajax, can update your script. With Twitter you can of course parse for public tweets.

If you want to make it truly seamless, setup Facebook Connect and Twitter Auth [a good idea in general for speeding up registration and logins] and prompt for the more advanced posting permission. Not everyone will agree but it guarantees a lot more rights.

Twitter method - https://dev.twitter.com/docs/api/1/post/statuses/update

Facebook method - http://developers.facebook.com/docs/reference/api/post/

Hi Ted,

Sorry for dragging up an old post but you seemed to be “in the know” so I’d like your input again if possible.

I’ve looked into this subject matter a little more. I’ve decided to use a simple “Like Button” provided by the Facebook Social Plugin. This posts a link on the “clicker’s” Facebook Wall (After asking them to login to facebook, if they aren’t already). You can also use the “FB.Event.Subscribe” function provided by them to monitor the likes. It says that you can use this function to record the likes in your database… This is exactly what I need.

The only problem is, I can’t seem to get it to work. I’ve followed the instructions on the Facebook Developer’s page but something is missing.

In their example, they are using a simple “alert” that flashes up with a message saying “You have liked the page…” when the event.subscribe function is triggered. I can’t even get this to work.

Here is my code:


<div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
    FB.init({
      appId      : 'xxxxxxxxxxxxxxxxx', // App ID
      channelURL : '//ivegotkids.com/', // Channel File
      status     : true, // check login status
      cookie     : true, // enable cookies to allow the server to access the session
      oauth      : true, // enable OAuth 2.0
      xfbml      : true  // parse XFBML
    });

    // Additional initialization code here
  };

  // Load the SDK Asynchronously
  (function(d){
     var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
     js = d.createElement('script'); js.id = id; js.async = true;
     js.src = "//connect.facebook.net/en_US/all.js";
     d.getElementsByTagName('head')[0].appendChild(js);
   }(document));
</script>


<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) {return;}
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1&appId=263505630361594";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<div class="fb-like" data-href="http://ivegotkids.com" data-send="false" data-width="450" data-show-faces="true" data-action="recommend" data-font="trebuchet ms"></div>

<script> FB.Event.subscribe('edge.create',
    function(response) {
        alert('You liked the URL: ' + response);
    }
);
</script>

Please could you help me figure out why this is isn’t working. Also - what do I have to replace the “alert” with to instead record the name of the clicker in my database?

There’s not a lot of discussion on that code but you may want to check out:

http://stackoverflow.com/questions/8082479/fb-event-subscribe-does-not-work

http://forum.developers.facebook.net/viewtopic.php?pid=362167