問題描述
我開發了一個 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模板網!