Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Basic Facebook login and data retrieval flow
// Check and verify user status or prompt for authorization
function checkUserStatus(response) {
var permissions = {
scope: '' // email
};
if ( isConnectedUser(response) )
return FB.api('/me', gotUserInfo);
return FB.login(checkUserStatus, permissions);
}
// Check if user is authorized and connected
function isConnectedUser(response) {
return (response && response.status && response.status === 'connected') ? true : false;
}
// Get and process user info
function gotUserInfo(info) {
console.log(info);
}
// Call it as following
FB.getLoginStatus(checkUserStatus);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.