Last active
August 29, 2015 14:05
-
-
Save jabranr/823ad833f6e4f98d12e6 to your computer and use it in GitHub Desktop.
Basic Facebook login and data retrieval flow
This file contains hidden or 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
// 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