Skip to content

Instantly share code, notes, and snippets.

Created February 20, 2015 10:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/4e38b6705a5d952a6b82 to your computer and use it in GitHub Desktop.
Save anonymous/4e38b6705a5d952a6b82 to your computer and use it in GitHub Desktop.
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