Skip to content

Instantly share code, notes, and snippets.

@maxcal
Created November 22, 2011 16:13
Show Gist options
  • Save maxcal/1386033 to your computer and use it in GitHub Desktop.
Save maxcal/1386033 to your computer and use it in GitHub Desktop.
FB.init Event
/**
* Demo: Using the fb.ready event
* @author max.calabrese@greenpeace.org
* @project Planet3
* @see https://gist.github.com/1386033
*/
// Listen for fb.ready event
jQuery(document).bind('fb.ready', function(){
// we can now safely use the FB SDK.
/****** DEMO: show a FB dialog ******/
var obj = {
method: 'feed',
link: 'https://developers.facebook.com/docs/reference/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
name: 'Facebook Dialogs',
caption: 'Reference Documentation',
description: 'Using Dialogs to interact with users.'
};
function callback(response) {
document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
}
FB.ui(obj, callback);
/****** END DEMO ******/
});
/**
* Load the FB SDK asyncronously and fire an event when it is ready.
* @author max.calabrese@greenpeace.org
* @project Planet3
* @see https://gist.github.com/1386033
*/
window.fbAsyncInit = function() {
/**
* This is the values for GP international - correct values needs to be
* set in the server-side template.
*/
FB.init({
appId: '206443473453',
status: true,
cookie: true,
xfbml: true
});
/**
* !!!!!!!
* Trigger a event when the sdk is initialized
* @see
*/
jQuery(document).trigger('fb.ready');
};
(function() {
var e = document.createElement('script');
e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
} ());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment