在搜索Facebook Graph API时,如何获得喜欢计数,搜索= xxx [英] How to get Likes Count when searching Facebook Graph API with search=xxx

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

问题描述

我目前正在使用Facebook图表api搜索来搜索帖子

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

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



阅读开发路线图( https://developers.facebook.com/roadmap/ )在7月10日之后进行更改,我被指示使用 summary = true param,但我不知道如何让这个工作与搜索?



从FB博客路线图。



< blockquote>

从comments中删除countGraph API连接我们正在删除
Graph API中'comments'连接上的未记录的'count'字段。请求code> {id} / comments?summary = true 如果
您希望包含计数的摘要字段(现在称为
'total_count' )


我尝试了各种组合,搜索了例子,但没有骰子。任何人都可以给我一些建议,如何获得新的摘要= true在搜索网址中工作以搜索帖子?

解决方案

在文档中找不到,但是对API的多次调用是不必要的。查询Feed或多个帖子时,可以使用摘要。在fields参数中指定。

  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
}
...
}
]
}

这将比为每个对象发出个别请求只是获取评论或喜欢的数量快得多。 / p>

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

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

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

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?

From FB blog on roadmap.

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

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?

解决方案

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)

This will return a response like this.

{
  "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.

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

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