Facebook 图形 API 仅返回某些网站的名称和 ID [英] Facebook graph API returns only name and id for some websites

查看:18
本文介绍了Facebook 图形 API 仅返回某些网站的名称和 ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一个 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 返回的每个字段.

例如,如果您希望返回字段 emailname,则必须将它们添加到请求中,如下所示:

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆