我在使用Koala 1.7.0rc1和新的Facebook图表api时遇到了问题。我正在尝试使用此请求[object_id]/likes?summary=1
检索帖子的数量。此查询适用于Facebook Graph Explorer,但我无法使用Koala访问“摘要”:
likes = graph.get_object("5718732097_10151698726822098", summary: 1){|data| data['likes']}
# OR
likes = graph.get_object("5718732097_10151698726822098/likes?summary=1")
答案 0 :(得分:6)
你应该这样做:
graph.get_object(your_post_id, :fields => "likes.summary(true)")
Facebook给出的api文档在这里有点误导: https://developers.facebook.com/docs/reference/api/post/
它表示summary = 1
应该是summary = true
在rails
答案 1 :(得分:5)
您需要从Koala的原始响应中获取摘要数据,如下所示:
likes = graph.get_object("5718732097_10151698726822098/likes?summary=1").
raw_response["summary"]["total_count"]