Home >Web Front-end >JS Tutorial >How Can I Retrieve Specific User Fields Using Facebook's JS SDK FB.api('/me') in Graph API v2.4 ?
Handling Field Returns in Facebook JS SDK's FB.api('/me') with Graph API v2.4
The Facebook JS SDK's FB.api('/me') method retrieves user information. However, in Graph API versions 2.4 and above, only the user's name and ID are returned by default. To retrieve additional fields, such as email, first name, last name, and birthday, developers must explicitly specify them.
Solution:
To manually specify the fields required, add the fields parameter to the API request, like this:
FB.api('/me', 'get', { access_token: token, fields: 'id,name,gender' }, function(response) { console.log(response); });
Background:
This change was introduced in Graph API v2.4 to improve performance on mobile networks. By default, nodes and edges no longer include likes and comments. Developers must explicitly request the fields they need for their GET requests.
Additional Resources:
The above is the detailed content of How Can I Retrieve Specific User Fields Using Facebook's JS SDK FB.api('/me') in Graph API v2.4 ?. For more information, please follow other related articles on the PHP Chinese website!