Facebook 图 API 从 2.3 升级到 2.4 后返回不完整的对象

Facebook graph API returning incomplete object after upgrading from 2.3 to 2.4

我正在尝试升级我的 Facebook GraphAPI 版本。我正在使用 koala gem 并且只有从 api v2.3 升级到更高版本时才会出现这种情况。

我使用 v2.3 发出以下请求并得到以下响应:

@graph = Koala::Facebook::API.new(fb_resp["access_token"])
fb_user = @graph.get_object("me")
# v2.3 response
{
"id"=>"10974014220671",
"email"=>"pam_lipnhdj_west@tfbnw.net",
"first_name"=>"Pam",
"gender"=>"female",
"last_name"=>"West",
"link"=>"https://www.facebook.com/app_scoped_user_id/109740146220671/",
"locale"=>"en_US",
"name"=>"Pam West",
"timezone"=>0,
"updated_time"=>"2017-03-01T14:53:49+0000",
"verified"=>false
}

#v2.4 response
{"name"=>"Pam West", "id"=>"10974014220671"}

我查看了 Facebook changelog,"me" 端点似乎没有任何变化。

有什么想法可以在哪里查看,或者这是否可能与考拉有关?我正在使用 gem "koala", "~> 2.4"

从 v2.4 开始,您必须在请求中包含您要查找的字段。

In the past, responses from Graph API calls returned a set of default fields. In order to reduce payload size and improve latency on mobile networks, we have reduced the number of default fields returned for most Graph API calls. In v2.4 you will need to declaratively list the response fields for your calls.

因此在您的情况下,您必须将 @graph.get_object("me") 替换为

@graph.get_object("me", { fields: [:id, :email, :first_name, :gender, :last_name, :link, :locale, :name, :timezone, :updated_time, :verified]})