如何使用图API获取共享计数

Ash*_*kar 136 facebook facebook-like facebook-graph-api

我可以使用PHP SDK和使用弃用的rest API获取URL的共享计数,但是没有找到使用图API获取URL的共享计数的方法.

有没有办法找出来?

cha*_*eet 270

以下是获取统计信息的API链接列表:

Facebook: https
://api.facebook.com/method/links.getStats urls = %%URL %% & format = json Reddit:http://buttons.reddit.com/button_info.json url = %% URL% %
LinkedIn:http
://www.linkedin.com/countserv/count/share url = %% urL %%& format = json Digg:http://widgets.digg.com/buttons/count url = %% urL %%
美味:http://feeds.delicious.com/v2/json/urlinfo/data?
url = %% URL %% StumbleUpon:http://www.stumbleupon.com/services/1.01/badge.getinfo url = %% URL %%
Pinterest:http://widgets.pinterest.com/v1/urls/count.json? source = 6&url =%%URL %%

编辑:删除了Twitter端点,因为该端点已被弃用.

编辑:Facebook REST API已弃用

  • Facebook链接不再有效.使用http://graph.facebook.com/?id=http://www.google.com (10认同)
  • 嗨,您好 !谢谢你的名单.我找不到https://api.facebook.com/method/links.getStats API端点的文档.它确实有效,但我想确保它不是即将退役的API版本的一部分.同样奇怪的是,没有身份验证就可以使用...你在facebook文档中看到了什么吗?它不是图API的一部分...... (8认同)
  • @MarkOverride是一个更优化的版本(更少的带宽)是http://graph.facebook.com/?fields=share&id=http://www.google.com.问题是这些新的端点受到严格的速率限制,并且在没有遇到上述限制的情况下很难在生产中使用它们.如果有人有不同的方法,请告诉我们. (8认同)
  • 每个请求的API调用限制是多少? (2认同)

ifa*_*our 200

更新 - 2015年4月:

如果要获取Like按钮中可用的计数,则应使用对象中的engagement字段og_object,如下所示:

https://graph.facebook.com/v2.2/?id=http://www.MY-LINK.com&fields=og_object{engagement}&access_token=<access_token>
Run Code Online (Sandbox Code Playgroud)

结果:

{
  "og_object": {
    "engagement": {
      "count": 93, 
      "social_sentence": "93 people like this."
    }, 
    "id": "801998203216179"
  }, 
  "id": "http://techcrunch.com/2015/04/06/they-should-have-announced-at-420/"
}
Run Code Online (Sandbox Code Playgroud)

使用Graph API可以使用:

http://graph.facebook.com/?id=YOUR_URL
Run Code Online (Sandbox Code Playgroud)

就像是:

http://graph.facebook.com/?id=http://www.google.com
Run Code Online (Sandbox Code Playgroud)

会回来:

{
   "id": "http://www.google.com",
   "shares": 1163912
}
Run Code Online (Sandbox Code Playgroud)

更新:虽然以上将回答如何获得份额.此数字等于您在Like按钮上看到的数字,因为该数字是以下数字的总和:

  • 此URL的喜欢数量
  • 此URL的份额数(包括将链接复制/粘贴回Facebook)
  • Facebook上有关此网址的故事的喜欢和评论数量
  • 包含此URL作为附件的收件箱邮件数.

因此,使用Graph API通过fql端点(link_stat表格)可以获得Like按钮编号:

https://graph.facebook.com/fql?q=SELECT url, normalized_url, share_count, like_count, comment_count, total_count,commentsbox_count, comments_fbid, click_count FROM link_stat WHERE url='http://www.google.com'
Run Code Online (Sandbox Code Playgroud)

total_count 是Like按钮中显示的数字.

  • 由于[v2.6 doc](https://developers.facebook.com/docs/graph-api/reference/v2.6/url)不允许你获得`share_count`,`like_count`和`comment_count`,似乎`fql`和REST API仍然是最好的选择......**但是2016年8月7日之后`fql`和REST API将不再可用!**有什么建议吗? (3认同)

fre*_*dev 21

你不应该使用graph api.如果你打电话:

要么

两者都会回归:

{
  "id": "http://www.apple.com",
  "shares": 1146997
}
Run Code Online (Sandbox Code Playgroud)

但显示的数字是:

  • 此URL的数量
  • 此URL的份额数(包括将链接复制/粘贴回Facebook)
  • 关于此网址的关于Facebook的故事的喜欢和评论的数量
  • 包含此URL作为附件的收件箱邮件数.

所以你必须使用FQL.
看看这个答案: 如何从文章中获取Facebook喜欢,分享,评论数量


Gio*_*sta 14

2016年8月7日之后,你仍然可以这样打电话:

http://graph.facebook.com/?id=https://www.apple.com/
Run Code Online (Sandbox Code Playgroud)

但响应格式将会有所不同:它不会

{
  "id": "http://www.apple.com",
  "shares": 1146997
}
Run Code Online (Sandbox Code Playgroud)

但相反它会

{
   "og_object": {
      "id": "388265801869",
      "description": "Get a first look at iPhone 7, Apple Watch Series 2, and the new AirPods \u2014 the future of wireless headphones. Visit the site to learn more.",
      "title": "Apple",
      "type": "website",
      "updated_time": "2016-09-20T08:21:03+0000"
   },
   "share": {
      "comment_count": 1,
      "share_count": 1094227
   },
   "id": "https://www.apple.com"
}
Run Code Online (Sandbox Code Playgroud)

所以你必须像这样处理响应:

reponse_variable.share.share_count
Run Code Online (Sandbox Code Playgroud)


Jua*_*che 8

我发现有用的,我在上面的一个链接上找到的是这个FQL查询,你可以通过查看link_stat表来询问一个链接的喜欢,总数,分享和点击次数

https://graph.facebook.com/fql?q=SELECT%20like_count,%20total_count,%20share_count,%20click_count,%20comment_count%20FROM%20link_stat%20WHERE%20url%20=%20%22http://google.com%22
Run Code Online (Sandbox Code Playgroud)

这将输出如下内容:

{
    data: [
        {
             like_count: 3440162,
             total_count: 13226503,
             share_count: 7732740,
             click_count: 265614,
             comment_count: 2053601
         }
    ]
}
Run Code Online (Sandbox Code Playgroud)

  • 自2016年8月8日起,FQL将不再可用且无法查询.要迁移您的应用,请使用API​​升级工具查看您可以进行的图谱API调用. (2认同)

Muh*_*eda 7

看看这个要点.它有关于如何获得以下服务的共享计数的片段:

  • Facebook的
  • 推特
  • 谷歌加
  • Pinterest的
  • LinkedIn
  • 偶然发现