2011-04-18 55 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