Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use the access token to get email address and some basic info of facebook users

I have the follwing code and would like to take the email address and other details of facebook user. This is the code that I have done.

FB.login(function(response) {
      if (response.authResponse) {
         //updateUserInfo(fb_id);
        console.log(response.authResponse);
        updateUserInfo(response.authResponse.userID);
        $.ajax({
           dataType: "json",
           url: 'http://graph.facebook.com/'+response.authResponse.userID+'/ fields=id,name,birthday,email,gender,hometown,location',
           success: function(data){
                fb_data = data;
               console.log(data);
            }});
 },{scope:'email'});

I am unable to get get the following details:

  1. birthday
  2. email
  3. Location
  4. hometown

However, I am able to get the first name and id.

If I am supposed to use the access token, how am i supposed to put it in the query? The email address is the vital information as my system identifies user by email address.

like image 933
madi Avatar asked Oct 21 '22 17:10

madi


1 Answers

You need following permission from user to get the data from Facebook.

  1. user_birthday for birthday
  2. email for email
  3. user_location for Location
  4. user_hometown for hometown

You can check this or this for other permissions and uses.

Then you will get the access token once user click on your Login button and authorize your App.

like image 139
amrendra Avatar answered Oct 23 '22 15:10

amrendra