首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何获取给定URL的Facebook相似/共享计数?

如何获取给定URL的Facebook相似/共享计数?
EN

Stack Overflow用户
提问于 2018-04-18 06:24:55
回答 2查看 0关注 0票数 0

我使用FacebookAPI来获取给定URL的类似/共享计数。奇怪的是,返回结果似乎不一致。例如,此页面返回结果:

代码语言:txt
复制
https://api.facebook.com/method/fql.query?query=select%20total_count,like_count,comment_count,share_count,click_count%20from%20link_stat%20where%20url='http://www.groupon.com/deals/seattlehelitourscom-by-classic-helicopter-corp'&format=json

然而,这一条没有:

代码语言:txt
复制
https://api.facebook.com/method/fql.query?query=select%20total_count,like_count,comment_count,share_count,click_count%20from%20link_stat%20where%20url='http://www.livingsocial.com/deals/278194-sunset-kayaking-hot-chowder'&format=json

第二个页面显然有一个共享计数,当我检查页面的HTML时,用于共享的URL就是我放在上面API请求中的URL。然而,API不响应任何数量的喜欢或共享的计数信息。

对于为什么API可能会响应某些URL而不是其他URL,有什么线索吗?

EN

回答 2

Stack Overflow用户

发布于 2018-04-18 15:06:52

从版本2.9开始,你可以创建图形API调用,其中ID是网址并选择'约会'字段,下面是图形浏览器中示例的链接。

https://developers.facebook.com/tools/explorer/?method=GET&path=%3Fid%3Dhttp%3A%2F%2Fcomunidade.edp.pt%26fields%3Dengagement&version=v2.9

票数 0
EN

Stack Overflow用户

发布于 2018-04-18 16:13:43

下面是一个非弃用的方式来获得给定的URL和共享计数(不需要访问令牌):

https://graph.facebook.com/?fields=og_object{likes.summary(total_count).limit(0)},share&id=https://www.stackoverflow.com

结果:

代码语言:javascript
复制
{
   "og_object": {
      "likes": {
         "data": [

         ],
         "summary": {
            "total_count": 83
         }
      },
      "id": "10151023731873397"
   },
   "share": {
      "comment_count": 0,
      "share_count": 2915
   },
   "id": "https://www.stackoverflow.com"
}

JQuery示例:

代码语言:javascript
复制
$.get('https://graph.facebook.com/'
    + '?fields=og_object{likes.summary(total_count).limit(0)},share&id='
    + url-goes-here,
    function (data) {
        if (data) {
            var like_count = data.og_object.likes.summary.total_count;
            var share_count = data.share.share_count;
        }
    });

参考:

https://developers.facebook.com/docs/graph-api/reference/url

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/-100008167

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档