1

I have 616 Facebook friends and Koala gem returns only 601.

Here is the code I use:

if user.facebook_identities.present?
  token = user.facebook_identities.first.token
  secret = GetFacebookEntry.new.execute[1]
  graph = Koala::Facebook::API.new(token, secret)
  friends = graph.get_connections("me", "friends", fields: "first_name, last_name, id")

  friends.map do |x|
    x.merge provider: :facebook,
            avatar_url: GetFacebookImageService.new(x['id']).execute,
            user_id: x['id']
  end
end

Any idea what could happen? Why those 10 friends are lost?

Boti
  • 3,275
  • 1
  • 29
  • 54
  • Maybe the results are being paged? https://developers.facebook.com/docs/graph-api/using-graph-api/v2.1 (The section is called Traversing Paged Results) – Max Oct 01 '14 at 14:40

0 Answers0