0

I have a facebook page where i post photos, they appear on the timeline. I see button there, near 'like' and 'comment', 'share'. and i see count for how many times this item was shared. How can i get this count?

Things i tried:

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

This gives:

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

Another try:

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

Gives same error.

Calling:

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

Has no key 'shares'.

I also tried the fql:

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

This gives:

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

I also tried:

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

This gives error: no such endpoint.

Anyone knows how can i get the number of shares for a photo? Is there a way at all?

4

1 回答 1

2

您需要使用格式为 的帖子 ID pageid_postedid。例如这张照片

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

照片10151690351123254
的id是页面的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'})
于 2013-06-23T15:39:20.770 回答