如何使用图形 API 获取分享计数

发布于 2024-11-02 10:00:03 字数 99 浏览 0 评论 0原文

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

有什么办法可以查到吗?

I can get the share count of an URL using PHP SDK and using the deprecated rest API, but didn't find a way to get the share counts of an URL using graph API.

Is there any way to find out?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(12

时光礼记 2024-11-09 10:00:03

更新 - 2015 年 4 月

如果您想获取“赞”按钮中可用的计数,则应使用 og_objectengagement 字段> 对象,如下所示:

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
}

更新: 而上面将回答如何获取共享数数。此数字等于您在点赞按钮上看到的数字,因为该数字是以下各项的总和:

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

因此,可以通过 fql 端使用 Graph API 获取“Like”按钮编号-point(link_stat 表):

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 是“赞”按钮中显示的数字。

UPDATE - April '15:

If you want to get the count that is available in the Like button, you should use the engagement field in the og_object object, like so:

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

Result:

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

It's possible with the Graph API, simply use:

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

something like:

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

Would return:

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

UPDATE: while the above would answer how to get the share count. This number is not equal to the one you see on the Like Button, since that number is the sum of:

  • The number of likes of this URL
  • The number of shares of this URL (this includes copy/pasting a link back to Facebook)
  • The number of likes and comments on stories on Facebook about this URL
  • The number of inbox messages containing this URL as an attachment.

So getting the Like Button number is possible with the Graph API through the fql end-point (the link_stat table):

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 is the number that shows in the Like Button.

墨落画卷 2024-11-09 10:00:03

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

两者都会返回:

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

但是显示的数字是以下内容的总和

  • 该 URL 的点赞
  • 数此 URL 的分享量(包括复制/粘贴链接回 Facebook)
  • Facebook 上有关此 URL 的故事的点赞和评论数量
  • 包含此 URL 作为附件的收件箱消息数量。

所以你必须使用 FQL。
看看这个答案:如何从文章中获取 Facebook 点赞数、分享数、评论数

You should not use graph api. If you either call:

or

both will return:

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

But the number shown is the sum of:

  • number of likes of this URL
  • number of shares of this URL (this includes copy/pasting a link back to Facebook)
  • number of likes and comments on stories on Facebook about this URL
  • number of inbox messages containing this URL as an attachment.

So you must use FQL.
Look at this answer: How to fetch facebook likes, share, comments count from an article

无人问我粥可暖 2024-11-09 10:00:03

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

After August 7, 2016 you can still make your call like this:

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

but the response format is going to be different: it won't be

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

but instead it will be

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

So you will have to process the response like this:

reponse_variable.share.share_count
小忆控 2024-11-09 10:00:03

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

What I found useful and I found on one link above is this FQL query where you ask for likes, total, share and click count of one link by looking at the link_stat table

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

That will output something like this:

{
    data: [
        {
             like_count: 3440162,
             total_count: 13226503,
             share_count: 7732740,
             click_count: 265614,
             comment_count: 2053601
         }
    ]
}
烂柯人 2024-11-09 10:00:03

查看此要点。它包含如何获取以下服务的共享计数的片段:

  • Facebook
  • Twitter
  • Google plus
  • Pinterest
  • LinkedIn
  • StumbledUpon

Check out this gist. It has snippets for how to get the sharing count for the following services:

  • Facebook
  • Twitter
  • Google plus
  • Pinterest
  • LinkedIn
  • StumbledUpon
二货你真萌 2024-11-09 10:00:03

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

  1. 如果您在“赞”按钮中使用的网址有重定向,该按钮实际上会显示重定向网址的计数与您正在使用的网址的计数。

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

希望这对某人有帮助

The facebook like button does two things that the API does not do. This might create confusion when you compare the two.

  1. If the URL you use in your like button has a redirect the button will actually show the count of the redirect URL versus the count of the URL you are using.

  2. If the page has a og:url property the like button will show the likes of that url instead of the url in the browser.

Hope this helps someone

柳若烟 2024-11-09 10:00:03

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

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

Simply type in https://graph.facebook.com/?fields=share&id=https://www.example.com and replace example with your url or page you are looking for.

Example of Google:
https://graph.facebook.com/?fields=share&id=https://www.google.com

怪我太投入 2024-11-09 10:00:03

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

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

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

when i used FQL I found the problem (but it is still problem)
the documentation says that the number shown is the sum of:

  • number of likes of this URL
  • number of shares of this URL (this
    includes copy/pasting a link back to Facebook)
  • number of likes and
    comments on stories on Facebook about this URL
  • number of inbox
    messages containing this URL as an attachment.

but on my website the shown number is sum of these 4 counts + number of shares (again)

不弃不离 2024-11-09 10:00:03

使用 FQL 您可以这样做:

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

Using FQL you could do that:

http://graph.facebook.com/fql?q=SELECT url, total_count FROM link_stat WHERE url='PASTE_YOUR_URL_HERE'
逆蝶 2024-11-09 10:00:03

有一个 ruby​​ gem - SocialShares

目前它支持以下社交网络:

  • facebook
  • twitter
  • google plus
  • reddit
  • linkedin
  • pinterest
  • stumbleupon
  • 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

There is a ruby gem for it - SocialShares

Currently it supports following social networks:

  • facebook
  • twitter
  • google plus
  • reddit
  • linkedin
  • pinterest
  • stumbleupon
  • vkontakte
  • mail.ru
  • odnoklassniki

Usage:

: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
夏日浅笑〃 2024-11-09 10:00:03

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

You can use the https://graph.facebook.com/v3.0/{Place_your_Page_ID here}/feed?fields=id,shares,share_count&access_token={Place_your_access_token_here} to get the shares count.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文