我开发了一个 WordPress 插件,用于使用 Facebook 进行社交登录.我正在使用 Facebook 图形 API /me
来检索用户详细信息.我的问题是,对于某些网站,当安装了 Facebook 登录插件时,我只能获得用户 ID 和名称.
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] => something@gmail.com
[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
)
仅获取名称和 ID 的站点可能出现哪些错误?
What might be the possibilities of the errors for the site that is getting only name and id?
正如 CBroe 在上述评论中已经指出的那样,Facebook API - 比版本 2.4 更新 - 更改了响应和发送请求的方式.
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.
您必须在请求中指定要从图形 API 返回的每个字段.
例如,如果您希望返回字段 email
和 name
,则必须将它们添加到请求中,如下所示:
For example, if you want the fields email
and name
returned, you must add them inside the request like this:
/me?fields=email,name
这篇关于Facebook 图形 API 仅返回某些网站的名称和 ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!