Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook graph API returns only name and id for some websites

I've developed a WordPress plugin for social login using Facebook. I'm using the Facebook graph API /me to retrieve the user details. My problem is that for some websites, when installed a Facebook login plugin, I'm only getting user ID and name.

Array (     [name] => John doe     [id] => 398463877009801 ) 

but same code is working well for some websites as well.

Array (     [id] => 398463877009801     [email] => [email protected]     [first_name] => John     [gender] => male     [last_name] => Doe     [link] => https://www.facebook.com/app_scoped_user_id/398463877009801/     [locale] => en_US     [name] => John Doe     [timezone] => 5.45     [updated_time] => 2015-05-03T11:24:16+0000     [verified] => 1 ) 

What might be the possibilities of the errors for the site that is getting only name and id?

like image 920
Jay Maharjan Avatar asked Jul 26 '15 06:07

Jay Maharjan


People also ask

What data can I get from Facebook Graph API?

The Graph API is the primary way to get data into and out of the Facebook platform. It's an HTTP-based API that apps can use to programmatically query data, post new stories, manage ads, upload photos, and perform a wide variety of other tasks.

Is Facebook Graph API deprecated?

API Version Deprecations: As part of Facebook's Graph API and Marketing API, please note the upcoming deprecations: August 3, 2021: Graph API v3. 3 will be deprecated and removed from the platform. August 25, 2021 Marketing API v9.

How do I get Facebook Page Insights on graph API?

You can access Page Insights by typing /insights after the name of your page in the URL field. This command will retrieve all of the Insights associated with your Page. Type "/insights" after your company name. Click the Submit button.


1 Answers

As CBroe already pointed out in the above comment, the Facebook API - newer than version 2.4 - changed the response and the way the requests are being sent.

You have to specify each field you want to be returned from the Graph API within your request.

For example, if you want the fields email and name returned, you must add them inside the request like this:

/me?fields=email,name 
like image 99
Răzvan Avatar answered Oct 11 '22 10:10

Răzvan