【问题标题】:How to get share counts using graph API如何使用图形 API 获取共享计数
【发布时间】:2011-08-07 15:24:45
【问题描述】:

我可以使用 PHP SDK 并使用已弃用的 rest API 获取 URL 的共享计数,但没有找到使用图形 API 获取 URL 共享计数的方法。

有什么办法可以查到吗?

【问题讨论】:

标签: facebook facebook-graph-api facebook-like


【解决方案1】:

您可以使用https://graph.facebook.com/v3.0/{Place_your_Page_ID here}/feed?fields=id,shares,share_count&access_token={Place_your_access_token_here} 来获取分享数。

【讨论】:

    【解决方案2】:

    【讨论】:

    • linkedin 一个不起作用(给出 403 访问被拒绝)
    • 每个请求的API调用限制是多少?
    • 您好!感谢这份清单。我找不到api.facebook.com/method/links.getStats API 端点的文档。它确实有效,但我想确保它不是即将停用的 API 版本的一部分。同样奇怪的是,无需身份验证即可使用...您在 facebook 文档中看到有关此的任何内容吗?它不是图形 API 的一部分...
    • Facebook 链接不再有效。使用graph.facebook.com/?id=http://www.google.com
    • @MarkOverride 一个更优化的版本(更少的带宽)是graph.facebook.com/?fields=share&id=http://www.google.com。问题是这些新端点受到严重的速率限制,并且很难在生产中使用它们而不遇到上述限制。如果有人有不同的方法,请告诉我们。
    【解决方案3】:

    只需输入https://graph.facebook.com/?fields=share&id=https://www.example.com 并将示例替换为您要查找的网址或页面。

    谷歌示例: https://graph.facebook.com/?fields=share&id=https://www.google.com

    【讨论】:

      【解决方案4】:

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

      http://graph.facebook.com/?id=https://www.apple.com/
      

      但响应格式会有所不同:不会是

      {
        "id": "http://www.apple.com",
        "shares": 1146997
      }
      

      但它会是

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

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

      reponse_variable.share.share_count
      

      【讨论】:

      • 但是 share_count 的值具有误导性,因为它指的是likes+shares 的总和
      • 我想你是对的,我的回答只是关于如何调用 API 的更新。我认为@freedev 关于共享计数的说法可能仍然是正确的。
      【解决方案5】:

      我发现有用并且我在上面的一个链接上发现的是这个 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
      

      这将输出如下内容:

      {
          data: [
              {
                   like_count: 3440162,
                   total_count: 13226503,
                   share_count: 7732740,
                   click_count: 265614,
                   comment_count: 2053601
               }
          ]
      }
      

      【讨论】:

      • 自 2016 年 8 月 8 日起,FQL 将不再可用且无法查询。要迁移您的应用,请使用 API 升级工具查看您可以进行的 Graph API 调用。
      【解决方案6】:

      更新 - 2015 年 4 月:

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

      https://graph.facebook.com/v2.2/?id=http://www.MY-LINK.com&fields=og_object{engagement}&access_token=<access_token>
      

      结果:

      {
        "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/"
      }
      

      可以使用 Graph API,只需使用:

      http://graph.facebook.com/?id=YOUR_URL
      

      类似:

      http://graph.facebook.com/?id=http://www.google.com
      

      会返回:

      {
         "id": "http://www.google.com",
         "shares": 1163912
      }
      

      更新: 虽然上面将回答如何获得 share 计数。该数字等于您在Like Button 上看到的数字,因为该数字是以下各项的总和:

      • 此网址的点赞数
      • 此 URL 的共享数量(包括复制/粘贴回 Facebook 的链接)
      • Facebook 上有关此 URL 的故事的点赞数和 CMET 数
      • 包含此 URL 作为附件的收件箱邮件数。

      因此,可以使用 Graph API 通过fql 端点(link_stat 表)获取 Like Button 编号:

      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'
      

      total_count 是点赞按钮中显示的数字。

      【讨论】:

      • 我没有得到某些对象的共享计数。我知道他们应该至少拥有一份股份。
      • @Fair,是的,有时数字不正确而且有点混乱。您可以使用其他答案建议的 fql 表,但仍然......有时数字也不正确!
      • 有没有可能分到几个网站?
      • 我一直用这个
      • 由于v2.6 doc 不会让你得到share_countlike_countcomment_count,看来fql 和REST API 仍然是最好的选择...... 但是在 2016 年 8 月 7 日之后,fql 和 REST API 都将不再可用! 有什么建议吗?
      【解决方案7】:

      查看this gist。它有关于如何获取以下服务的共享计数的 sn-ps:

      • 脸书
      • 推特
      • 谷歌加
      • Pinterest
      • 领英
      • 偶然发现

      【讨论】:

      • 这几年了。每个服务更新其 API 的频率,我怀疑它是否非常准确。
      【解决方案8】:

      它有一颗红宝石 - SocialShares

      目前支持以下社交网络:

      • 脸书
      • 推特
      • 谷歌加
      • reddit
      • 已链接
      • 兴趣
      • 偶然发现
      • vkontakte
      • mail.ru
      • odnoklassniki

      用法:

      :000 > url = 'http://www.apple.com/'
        => "http://www.apple.com/"
      :000 > SocialShares.facebook url
        => 394927
      :000 > SocialShares.google url
        => 28289
      :000 > SocialShares.twitter url
        => 1164675
      :000 > SocialShares.all url
        => {:vkontakte=>44, :facebook=>399027, :google=>28346, :twitter=>1836, :mail_ru=>37, :odnoklassniki=>1, :reddit=>2361, :linkedin=>nil, :pinterest=>21011, :stumbleupon=>43035}
      :000 > SocialShares.selected url, %w(facebook google linkedin)
        => {:facebook=>394927, :google=>28289, :linkedin=>nil}
      :000 > SocialShares.total url, %w(facebook google)
        => 423216
      :000 > SocialShares.has_any? url, %w(twitter linkedin)
        => true
      

      【讨论】:

        【解决方案9】:

        使用 FQL 你可以做到这一点:

        http://graph.facebook.com/fql?q=SELECT url, total_count FROM link_stat WHERE url='PASTE_YOUR_URL_HERE'
        

        【讨论】:

          【解决方案10】:

          facebook like 按钮做了 API 不做的两件事。当您比较两者时,这可能会造成混淆。

          1. 如果您在点赞按钮中使用的 URL 具有重定向,则该按钮实际上会显示重定向 URL 的计数与您正在使用的 URL 的计数。

          2. 如果页面有 og:url 属性,点赞按钮将显示该 url 的点赞,而不是浏览器中的 url。

          希望这对某人有所帮助

          【讨论】:

            【解决方案11】:

            当我使用 FQL 时,我发现了问题(但仍然是问题) 文档说显示的数字是以下各项的总和:

            • 此网址的点赞数
            • 此 URL 的共享数(此 包括将链接复制/粘贴回 Facebook)
            • 点赞数和 cmets 在 Facebook 上关于此 URL 的故事
            • 收件箱数 包含此 URL 作为附件的邮件。

            但在我的网站上显示的数字是这 4 个计数的总和 + 共享数(再次)

            【讨论】:

              【解决方案12】:

              您不应该使用图形 api。如果您致电:

              两者都会返回:

              {
                "id": "http://www.apple.com",
                "shares": 1146997
              }
              

              但显示的数字是的总和:

              • 此网址的点赞数
              • 此 URL 的共享数量(包括复制/粘贴链接回 Facebook)
              • Facebook 上有关此 URL 的故事的点赞数和 CMET 数
              • 包含此 URL 作为附件的收件箱邮件数。

              所以你必须使用 FQL。
              看看这个答案:How to fetch facebook likes, share, comments count from an article

              【讨论】:

              • 你是绝对正确的,total_shares 是 cmets+likes+shares 的总和,但我请求的页面显示 share_i_have = total_shares + likes
              猜你喜欢
              • 2018-01-18
              • 2020-10-14
              • 1970-01-01
              • 2012-12-20
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2021-09-07
              • 1970-01-01
              相关资源
              最近更新 更多