Facebook 图形 API 仅返回某些网站的名称和 ID

Facebook graph API returns only name and id for some websites(Facebook 图形 API 仅返回某些网站的名称和 ID)
本文介绍了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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)