2011-04-18 56 views
131

如何获得份额数我可以使用PHP SDK和使用过时的其余API的URL的股数,但没有找到一种方式来获得使用图形API的URL的份额数。使用图形API

有什么方法可以找出?

+0

获取您的解决方案在这里http://stackoverflow.com/questions/6137414/how-to-fetch-facebook-likes-share-comments-count-from-一篇文章 – 2013-06-14 14:28:10

+0

请检查答案在这里:http://stackoverflow.com/questions/9728279/getting-the-facebook-like-share-count-for-a-given-url/35062056#35062056 – 2016-01-28 12:54:07

+0

Post 8月8日, 2016(非弃用)回答:http://stackoverflow.com/a/39379251/4607317 – 2016-10-17 19:45:06

回答

-2

我不认为这是有可能得到像从图形API的数量,你应该使用FQL link_stat table。 FQL不被弃用。

+2

向下投票,因为这是不正确的,根据@chandrajeet回答 – Luke 2014-03-18 08:57:10

197

更新 - 四月'15:

如果你想获得那就是在Like按钮可用计数,你应该使用engagement字段中og_object对象,像这样:

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

这是可能的图形API,只需使用:

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

类似:

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

将返回:

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

UPDATE:而上面会回答如何获得分享伯爵。这个数字是等于你在Like Button看到一个,因为这个数字的总和:

  • 这个URL
  • ,此网址的股份数量的喜欢的(这包括数将链接复制/粘贴回Facebook)
  • Facebook上关于此URL的点赞和评论数
  • 包含此URL作为附件的收件箱邮件的数量。

因此获得Like按钮数量是可能通过fql终点的图形API(在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是显示了Like按钮的数量。

+0

我没有得到某些对象的份额。我知道他们应该至少有一个份额。 – 2011-08-10 10:15:47

+1

@Fair,是的,有时候这个数字是不正确的,这有点令人困惑。您可以使用其他答案建议的fql表,但仍然...有时数字也不正确! – ifaour 2011-08-10 10:40:57

+0

是否有可能购买少量网站的股份? – Aziz 2012-02-17 08:24:12

21

你不应该使用图形api。如果您透过电话:

都将返回:

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

但显示的数字是的总和:

  • 数目这个URL
  • 数的这个URL的股的喜欢的(这包括复制/粘贴链接回到Facebook)的
  • 数Facebook上有关此URL的故事的评论和评论
  • 包含此URL作为附件的收件箱邮件的数量。

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

+0

你是绝对正确的,通过total_shares是的评论+喜欢+股 但我请求的页面总和,显示shares_i_have = total_shares +喜欢 – Aziz 2012-02-22 05:58:29

1

当我用FQL我发现这个问题(但它仍然是问题) 的文件说,显示的数字是的总和:

  • 数量的这种喜欢的URL
  • 号,此网址的股份(此 包括复制/粘贴链接回到Facebook的)这个网址在Facebook上
  • 号喜欢和 意见对故事
  • 收件箱号码 包含此URL作为附件的邮件。

,但在我的网站所示数量为这4个计数总和+股数(再次)

4

像按钮Facebook的做了两两件事,该API不会做。当你比较两者时,这可能会造成混乱。

  1. 如果你在像按钮使用URL有重定向的按钮将实际显示重定向URL与您所使用的URL的数量的计数。

  2. 如果页面有一个og:url属性,like按钮将显示喜欢的URL,而不是浏览器中的URL。

希望这可以帮助别人

267

这里的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%%
美味:
的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已被弃用

+4

哇。令人敬畏的集合! – ruX 2014-01-16 12:31:01

+1

linkedin没有工作(给403访问被拒绝) – 2014-02-23 15:42:22

+1

我已经修复了linkedin的url。 – Ahmed 2014-03-18 07:25:04

1

使用FQL,你可以这样做:

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

有它红宝石宝石 - SocialShares

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

  • facebook
  • 叽叽喳喳
  • 谷歌加
  • 书签交易
  • 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 
7

结帐this gist。它有如何获得以下服务共享计数片段:

  • Facebook的
  • Twitter的
  • 谷歌,加上
  • Pinterest的
  • LinkedIn
  • StumbledUpon
+0

这是几年的历史。每个服务更新其API的频率,我怀疑它是非常准确的。 – subvertallchris 2015-04-14 18:36:03

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 

这将输出这样的事情:

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

截至2016年8月8日,FQL将不再可用且无法查询。要迁移您的应用,请使用API​​升级工具查看您可以改为创建的图表API调用。 – 2016-08-04 12:52:47

11

8月7日以后年,2016年仍然可以使您的通话像这样:

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 
+1

但SHARE_COUNT值是一种误导,因为它是指喜欢+股 – 2017-03-05 10:21:29

+0

我想你是对的总和,我的回答只是如何调用API的更新。我认为@freedev关于股票数量的评论可能仍然是正确的。 – 2017-03-08 09:14:40

+0

太棒了!多数民众赞成唯一一个真正有效的,你不需要一个应用程序ID! – neoswf 2018-02-21 11:30:27