簡體   English   中英

Python / Facebook-SDk如何獲取頁面上發布的照片​​的共享計數

[英]Python/Facebook-SDk How to get shares count for a photo posted on a page

我有一個Facebook頁面,我在其中發布照片,它們顯示在時間軸上。 我在“喜歡”和“評論”,“分享”附近看到按鈕。 我看到該項目被共享了多少次。 我如何獲得此計數?

我嘗試過的事情:

img_id_on_facebook = '123'
fb = facebook.GraphAPI(token)
fb.request(path='/123/shares')

這給出:

{
  "error": {
    "message": "Unsupported get request.", 
    "type": "GraphMethodException", 
    "code": 100
  }
}

另一種嘗試:

fb.request(path='/123/', args={'fields': 'shares'})

給出相同的錯誤。

致電:

fb.request(path='/123/')

沒有關鍵的“份額”。

我也嘗試過fql:

fb.fql('SELECT shares_count FROM link_stat WHERE url=https://facebook.com/123')

這給出:

GraphAPIError: Impersonated access tokens can only be used with the Graph API

我也嘗試過:

fb.request(path='/[PAGE_ID]_[PHOTO ID]/')

這給出了錯誤:沒有這樣的端點。

誰知道我如何獲得照片的共享數量? 有沒有辦法?

您需要使用post id,其格式應為pageid_postedid 例如這張照片

https://www.facebook.com/photo.php?fbid=10151690351123254&set=a.100690783253.87226.80329313253&type=1&theater

照片的ID是10151690351123254
該頁面的ID為80329313253

post_id為80329313253_10151690351363254

因此,您可以將共享請求為80329313253_10151690351363254?fields=shares

{
  "shares": {
    "count": 4435
  }, 
  "id": "80329313253_10151690351363254", 
  "created_time": "2013-06-19T18:02:31+0000"
}

或者在您的情況下使用Python

fb.request(path='/80329313253_10151690351363254', args={'fields': 'shares'})

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM