Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook only returning name and id of user

I am trying to login to my website using my Facebook account but Facebook is giving name and id only that is not enough to login user. Before I was getting full information like firstname, lastname, email etc.

Data provided by facebook now:

stdClass Object
(
    [name] => FName LName
    [id] => 236189327864097
)

I am using Oauth v2.0 to login users through Facebook to my website.

like image 794
Wolfack Avatar asked Jul 29 '15 06:07

Wolfack


2 Answers

FB.api('/me?fields=first_name, last_name, picture, email', function(response) {
          console.log(response);
          document.getElementById('status').innerHTML =
            'Thanks for logging in, ' + response.first_name + '!';
        });

This worked for me. Pass email after /me?fields= in FB.api request.

like image 148
Swati Pardeshi Avatar answered Oct 12 '22 12:10

Swati Pardeshi


Pass by parameters the fields that you looking for:

var request = new OAuth2Request("GET", new Uri("https://graph.facebook.com/me?fields=birthday,email,name,id"), null, eventArgs.Account);
like image 38
Diego Venâncio Avatar answered Oct 12 '22 11:10

Diego Venâncio