Get Facebook share/like/comment count of URL

前端 未结 2 1100
别那么骄傲
别那么骄傲 2021-01-01 05:36

Prior to today, I used the following URL to get the Facebook share/like/comment count of a URL:

https://api.facebook.com/method/links.getStats?format=json&am         


        
相关标签:
2条回答
  • 2021-01-01 05:46

    Looks like a bug in fb-api.

    My solution:

    1. receive the number of shares/comments as you describe in your question with

      graph.facebook.com/?fields=og_object{id},share&id=https://stackoverflow.com/

    2. save shares/comments count

    3. save fb object-id of url

      og_object->id

    4. get likes count with (max limit is 1000, then you can use paging):

      graph.facebook.com/OBJECT_ID/likes?access_token=ACCESS_TOKEN&pretty=1&limit=1000

    UPD 2016-08-22

    I found a solution that allows you to get the number of likes/reposts/comments in one step:

    https://graph.facebook.com/?fields=og_object{likes.limit(0).summary(true)},share&ids=http://google.com,http://twitter.com

    0 讨论(0)
  • 2021-01-01 05:59

    It is not currently possible. Facebook is adding likes/shares/comments for URLs and returning them as shared_count. Not possible to return correct number of individual likes/shares/comments, and that is not clear in the Graph API documentation. Not clear if it is a bug or a documentation error.

    The old Rest API that provided this data was turned off on the 18th August.

    There is a comment from a Facebook engineer explaining this in reply to a bug report, in the answer to this Stack Overflow question: Getting Facebook Share, Like and Comment Counts for a Given URL with API Graph v2.6

    You can also subscribe to this bug report at Facebook, but is a bit old with still no solution: https://developers.facebook.com/bugs/748651458568287/

    0 讨论(0)
提交回复
热议问题