ruby-on-railsfacebookfacebook-graph-apikoalakoala-gem

Koala - get number of likes for a post


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")

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