Created
November 22, 2011 16:13
-
-
Save maxcal/1386033 to your computer and use it in GitHub Desktop.
FB.init Event
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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 ******/ | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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