Skip to content

Instantly share code, notes, and snippets.

@alexkojin
Created December 15, 2008 09:27
Show Gist options
  • Save alexkojin/35913 to your computer and use it in GitHub Desktop.
Save alexkojin/35913 to your computer and use it in GitHub Desktop.
var FBSIY = {
postTemplateId:null,
favoriteTemplateId:null,
init:function(){
FB_RequireFeatures(["XFBML"], function()
{
FB.Facebook.init(window.api_key, "/facebook_sessions/finish_login/xd_receiver.htm");
});
},
ensure_init: function(callback) {
if(!window.api_key) {
window.alert("api_key is not set");
}
if(window.is_initialized) {
callback();
} else {
FB_RequireFeatures(["XFBML"], function() {
// FB.FBDebug.logLevel = 4;
// FB.FBDebug.isEnabled = true;
FB.Facebook.init(window.api_key, "/facebook_sessions/facebook_finish/xd_receiver.htm");
window.is_initialized = true;
callback();
});
}
},
showFeedDialog: function(){
this.ensure_init(function() {
FB.Connect.showFeedDialog("39681117843", {'description':'some description'});
});
},
postToFeed: function(data){
FB.Connect.showFeedDialog(this.postTemplateId, data);
},
favoriteToFeed: function(data){
FB.Connect.showFeedDialog(this.favoriteTemplateId, data);
},
login: function() {
FB.Connect.requireSession();
this.ensure_init(function() {
FB.Facebook.get_sessionState().waitUntilReady(function() {
var user = FB.Facebook.apiClient.get_session() ? FB.Facebook.apiClient.get_session().uid : null;
window.location = '/facebook_sessions/authenticate';
});
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment