Created
February 20, 2015 10:54
-
-
Save anonymous/4e38b6705a5d952a6b82 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
function fb_login(){ | |
FB.login(function(response) { | |
if (response.authResponse) { | |
console.log('Welcome! Fetching your information.... '); | |
//console.log(response); // dump complete info | |
access_token = response.authResponse.accessToken; //get access token | |
user_id = response.authResponse.userID; //get FB UID | |
FB.api('/me?fields=id,name,friendlists', function(response) { | |
user_email = response.email; //get user email | |
console.log(response); | |
alert(user_email); | |
// you can store this data into your database | |
}); | |
} else { | |
//user hit cancel button | |
console.log('User cancelled login or did not fully authorize.'); | |
} | |
}, { | |
scope: 'publish_stream,email,read_friendlists' | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment