Home > Web Front-end > JS Tutorial > How Can I Retrieve More Than Just Name and ID Using FB.api('/me') After Graph API v2.4?

How Can I Retrieve More Than Just Name and ID Using FB.api('/me') After Graph API v2.4?

Patricia Arquette
Release: 2024-12-22 01:37:36
Original
313 people have browsed it

How Can I Retrieve More Than Just Name and ID Using FB.api('/me') After Graph API v2.4?

Get More than Name and ID with FB.api('/me') after Graph API v2.4

When retrieving basic information using the Facebook API's FB.api('/me'), only the user's name and ID may be returned. To obtain additional fields such as email, first name, last name, and birthday, it is necessary to specify them explicitly.

The Graph API version 2.4 and later requires manual field specification. The following changes should be made to the provided code:

FB.api('/me', 'get', { access_token: token, fields: 'id,name,email,first_name,last_name,birthday' }, function(response) {
  console.log(response);
});
Copy after login

In this updated code, the 'fields' parameter lists the desired fields to be returned. By specifying these fields, the API call will now provide a more comprehensive response.

For further reference, consult the following documentation:

  • [Graph API v2.4 Changelog](https://developers.facebook.com/docs/apps/changelog#v2_4)
  • [FB.api Reference](https://developers.facebook.com/docs/javascript/reference/FB.api)

The above is the detailed content of How Can I Retrieve More Than Just Name and ID Using FB.api('/me') After Graph API v2.4?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template