3

I'm facing an issue using Koala 1.7.0rc1 and the new Facebook graph api. I'm trying to retrieve number of likes for a post using this request [object_id]/likes?summary=1. This query works in Facebook Graph Explorer but I cannot access 'summary' using Koala :

likes = graph.get_object("5718732097_10151698726822098", summary: 1){|data| data['likes']}
# OR
likes = graph.get_object("5718732097_10151698726822098/likes?summary=1")
djot
  • 2,952
  • 4
  • 19
  • 28
titibouboul
  • 1,348
  • 3
  • 16
  • 30

2 Answers2

6

You should do:

graph.get_object(your_post_id, :fields => "likes.summary(true)")

The api documentation that Facebook gave is kind of misleading here: https://developers.facebook.com/docs/reference/api/post/

It says summary = 1 which should be summary = true in rails

Runbai Ma
  • 141
  • 1
  • 5
5

You'll need to get the summary data from the raw response in Koala, like so:

likes = graph.get_object("5718732097_10151698726822098/likes?summary=1").
              raw_response["summary"]["total_count"]