Search code examples
facebookfacebook-graph-apikoala-gem

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


I'm trying to upgrade my Facebook GraphAPI version. I'm using the koala gem and this only occurs when upgrading from the api v2.3 to anything greater.

With v2.3 I make the following request and get the following response:

@graph = Koala::Facebook::API.new(fb_resp["access_token"])
fb_user = @graph.get_object("me")
# v2.3 response
{
"id"=>"10974014220671",
"email"=>"[email protected]",
"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"}

I've looked in the Facebook changelog and there doesn't appear to be any changes to the "me" endpoint.

Any ideas where to look or if this may an issue with Koala? I'm using gem "koala", "~> 2.4"


Solution

  • Since the v2.4, you have to include the fields you're looking for in your request.

    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.

    So in your case, you have to replace @graph.get_object("me") by

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