Created
May 12, 2009 02:16
-
-
Save rubymerchant/110276 to your computer and use it in GitHub Desktop.
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
<fb:login-button onlogin="ask_for_publish_stream_permission();"></fb:login-button> | |
function ask_for_publish_stream_permission(){ | |
facebook_prompt_permission('publish_stream', function(accepted) { | |
if(accepted) { | |
/* Call TA to create/login the fb user */ | |
new Ajax.Request('/fb_connect/create_user', | |
{ | |
method:'post', | |
parameters: { | |
facebook_uid: FB.Facebook.apiClient.get_session().uid | |
}, | |
onSuccess: function(data){ | |
var response = data.responseText; | |
if(response == "Success"){ | |
ajax_login_trigger = document.createElement('a'); | |
ajax_login_trigger.href = "/fb_connect/link_accounts"; | |
var valid = new lightbox(ajax_login_trigger); | |
valid.activate(); | |
} | |
}, | |
onFailure: function(){ alert('Something went wrong...') } | |
}); | |
} | |
else { | |
/* If user has already installed the application but didn't give the extended permissions */ | |
/* Should we still log them in? */ | |
} | |
}); | |
} | |
function facebook_prompt_permission(permission, callbackFunc) { | |
//check is user already granted for this permission or not | |
FB.Facebook.apiClient.users_hasAppPermission(permission, | |
function(result) { | |
// prompt offline permission | |
if (result == 0) { | |
// render the permission dialog | |
FB.Connect.showPermissionDialog(permission, callbackFunc); | |
} else { | |
// permission already granted. | |
callbackFunc(true); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment