ClickOnChris

Christopher G Johnson: programmer, entrepreneur

Facebook Javascript SDKs – Old vs. New

without comments

There are two ways to handle initializing your fb:serverFBML tags

1 – using the New Javascript SDK
doc: http://developers.facebook.com/docs/reference/javascript/

(identified by the js library http://connect.facebook.net/en_US/all.js)

<script src="http://connect.facebook.net/en_US/all.js"></script> 
<script type="text/javascript">
   FB.init({appId: 'your app id',
        status: true,
      cookie: true,
      xfbml: true});
   FB.Event.subscribe('auth.sessionChange', function(response) {
     if (response.session) {
       // A user has logged in, and a new cookie has been saved
     } else {
       // The user has logged out
     }
   });
</script>

2 – Using the Old Javascript SDK
which is what our friends at StackOverflow have done. I reference this thread because it kept coming up while I was solving this problem, and the solution they give is outdated.

http://stackoverflow.com/questions/820421/can-i-use-facebooks-fbfriend-selector-in-an-iframe

(identified by the js library http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php and xd_receiver.html)
doc:http://developers.facebook.com/docs/reference/oldjavascript/


<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>
<script type="text/javascript">
    FB_RequireFeatures(
        ["CanvasUtil"],
        function(){
                 FB.XdComm.Server.init('/xd_receiver.html');
                 FB.CanvasClient.startTimerToSizeToContent();
        }
    );
</script>

<script type="text/javascript">
    FB_RequireFeatures(["XFBML"], function(){ FB.Facebook.init("Your Facebook API Key", "/xd_receiver.html"); });       
</script>

Written by clickonchris

November 8th, 2010 at 11:48 pm

Posted in Facebook,Javascript

Leave a Reply

Switch to our mobile site