Facebook only returning name and id of user
Solution 1
Looks like you're using v2.4 of the Graph API. See
Declarative Fields
To try to improve performance on mobile networks, Nodes and Edges in v2.4 requires that you explicitly request the field(s) you need for your GET requests. For example,GET /v2.4/me/feed
no longer includes likes and comments by default, butGET /v2.4/me/feed?fields=comments,likes
will return the data. For more details see the docs on how to request specific fields.
To get an idea how to use the so-called field expansion, have a look at
Solution 2
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.
Solution 3
If you using PHP, you need to read also this article:
https://developers.facebook.com/docs/facebook-login/permissions/v2.4
Basically, Fb says about email
that
Note, even if you request the email permission it is not guaranteed you will get an email address. For example, if someone signed up for Facebook with a phone number instead of an email address, the email field may be empty.
Solution 4
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);
Comments
-
Wolfack almost 2 years
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.
-
Tobi almost 9 years@RaghubendraSingh Yes, if you're using v2.4.
-
Wolfack almost 9 yearsadded fields in the url called using CallAPI function and the desired results. Relaxed now.
-
Admin over 8 yearsThanks for this. I would also suggest that you edit your answer to add this link aiming the phonegap facebook plugin users: github.com/Wizcorp/phonegap-facebook-plugin/issues/1092
-
user43286 over 7 yearsIt's not working for the below url '/me/friends?fields=first_name, last_name, picture, email',