Question

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")
Was it helpful?

Solution

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

OTHER TIPS

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"]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top