我正在使用Restfb并希望获得有关某个页面上的帖子的一般信息。我想知道是否有办法获得包含每个反应的total_count的摘要?类似的东西:
“摘要”:{ “total_count”:51, “total_count_HAHA”:23, “total_count_LOVE”:28, “viewer_reaction”:“无” }
我只能使用提供的文档检索total_count。 我尝试在线搜索解决方案,常用的(在其他API中)是使用别名字段。不幸的是,我在Restfb中找不到任何有关别名的信息。关于如何克服这一挑战的任何想法? : - )
答案 0 :(得分:0)
我是Restfb的新手,并致力于类似的案例。我发现了这个(归功于这个人here)
JsonObject obj= facebookClient.fetchObject(post.getId(),JsonObject.class,
Parameter.with("fields",
"reactions.type(LOVE).limit(0).summary(total_count).as(reactions_love),"+
"reactions.type(WOW).limit(0).summary(total_count).as(reactions_wow),"+
"reactions.type(HAHA).limit(0).summary(total_count).as(reactions_haha),"+
"reactions.type(LIKE).limit(0).summary(total_count).as(reactions_like),"+
"reactions.type(ANGRY).limit(0).summary(total_count).as(reactions_angry),"+
"reactions.type(SAD).limit(0).summary(total_count).as(reactions_sad)"));
它将返回此响应(在此示例中,帖子上没有任何反应)。您的Facebook客户端应配置为使用图API的v2.6 希望这会有所帮助:)
{"reactions_haha":{"summary":{"total_count":0},"data":[]},"reactions_angry":{"summary":{"total_count":0},"data":[]},"reactions_sad":{"summary":{"total_count":0},"data":[]},"reactions_like":{"summary":{"total_count":0},"data":[]},"id":"id_of_post","reactions_love":{"summary":{"total_count":0},"data":[]},"reactions_wow":{"summary":{"total_count":0},"data":[]}}