使用 search=xxx 搜索 Facebook Graph API 时如何获得点赞数 [英] How to get Likes Count when searching Facebook Graph API with search=xxx

查看:30
本文介绍了使用 search=xxx 搜索 Facebook Graph API 时如何获得点赞数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用 Facebook 图形 API 搜索来搜索帖子

I am currently using Facebook graph api search to search posts as

http://graph.facebook.com/search?q=iwatch&type=post&access_token=xxxxx 

它以 JSON 格式的字段返回,并用于包含给定帖子的 like:count.

It returns in JSON format fields and use to include the like:count for a given post.

阅读开发路线图 (https://developers.facebook.com/roadmap/) 以了解 7 月 10 日之后的变化我被指示使用 summary=true 参数,但我不知道如何让它与搜索一起工作?

After reading the dev roadmap (https://developers.facebook.com/roadmap/) for changes after July 10th I am instructed to use the summary=true param but I have no idea how to get this to work with search?

来自关于路线图的 FB 博客.

From FB blog on roadmap.

从评论"图形 API 连接中删除计数"我们正在删除评论"连接中未记录的计数"字段图 API.如果出现以下情况,请明确请求 {id}/comments?summary=true您想要包含计数的汇总字段(现在称为'total_count')

Removing 'count' from 'comments' Graph API connection We are removing the undocumented 'count' field on the 'comments' connection in the Graph API. Please request {id}/comments?summary=true explicitly if you would like the summary field which contains the count (now called 'total_count')

我尝试了各种组合并搜索了示例,但没有骰子.谁能给我一些关于如何让新的 summary=true 在搜索 URL 中工作以搜索帖子的建议?

I have tried various combinations and searched for examples but no dice. Can anyone give me some advice on how to get the new summary=true to work within a search URL for searching posts?

推荐答案

在文档中找不到这个,但不需要多次调用 API.您可以在查询提要或多个帖子时使用摘要.在 fields 参数中指定此项.

Couldn't find this in the documentation but multiple calls to the API are not necessary. You can use summary when querying a feed or multiple posts. Specify this in the fields parameter.

https://graph.facebook.com/PAGE_ID/feed?fields=comments.limit(1).summary(true),likes.limit(1).summary(true)

这将返回这样的响应.

{
  "data": [
    {
      ....
      "summary": {
        "total_count": 56
      }
      ...
    }, 
    {
      ....
      "summary": {
        "total_count": 88
      }
      ...
    }
  ]
}

这比仅仅为了获得评论或喜欢的数量而对每个对象进行单独请求要快得多.

This will be much faster than making individual requests for each object just to get the number of comments or likes.

这篇关于使用 search=xxx 搜索 Facebook Graph API 时如何获得点赞数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆