1

The Short Version:

"I can visit the public page without being logged into Facebook and see underneath the post is says "2155 shares" I would like to know how to access that number through the API"

The Details:

I'm trying to use the newest version (v2.5) of the graph HTTP API to determine the total share count for a public video. The problem is FB seems to have changed the API enough that older posts on SO no longer answer this question.

Looking at the Graph API Documentation it appears that video nodes now have the "sharedposts" edge. However, calling this route with summary=true only returns a few of the shares and no value for a total count. This returns counts for comments and likes so I'm not using the endpoints incorrectly or messing up my authorization.

I've also tried to use the URL Node but this doesn't seem to do much with links inside of Facebook. I simply get a JSON response with an 'id' field with the same url I supplied as a request parameter. Seems like this route is meant to be used for links to content outside of Facebook.

I've tried the above methods with multiple videos on multiple public pages so I don't think it is due to the group owners restricting access, unless this is the new default.

It seems arbitrary that I would be allowed access to total counts for comments and likes, but not shares. Is there some legacy way to do this or am I out of luck for now?

  • 1
    _“This works as expected for comments and likes so I'm not using the endpoints incorrectly”_ – neither https://developers.facebook.com/docs/graph-api/reference/v2.5/video/sharedposts nor https://developers.facebook.com/docs/graph-api/reference/v2.5/object/sharedposts mention any `total_count` property or `summary`. And since `/sharedposts` delivers actual post objects, what return you get will depend on whether your app is allowed to “see” those posts or not (which for posts by normal users that did not grant your app `user_posts` permission, will be a “not”.) – CBroe Nov 05 '15 at 11:29
  • This is true, but I can visit the public page without being logged into Facebook and see underneath the post is says "2155 shares" I would like to know how to access that number through the API. –  Nov 05 '15 at 21:17

1 Answers1

1

You should query the Post element containing the Video element.

Each video posted is also contained in a post element.
The post id is then composed of the video id prepended with the posting entities id (user, page etc'), separated with an underscore.
It then looks like: user-id_video-id.

Then using the Graph API to get the share count of a post is straightforward:

GET /v2.5/{post-id}?fields=shares  

Example

Lets take a video from the BBC page:

https://www.facebook.com/bbcnews/videos/10153524838517217/
(Please tell me if the link is broken. I'll switch it to something newer :))

Video id : 10153524838517217
Page id (see below): 228735667216

--> Post id: 228735667216_10153524838517217

And the request would be:

GET /v2.5/228735667216_10153524838517217?fields=shares  

(open in the Graph API explorer)


Page id

to get the page id, you could query the video element for the from field.

GET /v2.5/10153524838517217?fields=from  
inbarda
  • 26
  • 2
  • Thanks! Thought this question was dead :) –  Apr 11 '16 at 00:57
  • @inbarda you are a king! (or a queen!). I looked for a long long time for a way to fetch the sharecount of a video, In no place of the Graph API I couldn't find this thing of a post object element that containing the video, with this method. I can confirm this works also in Graph API v2.11. This answer should be marked as the correct one. Thanks! – Maor Barazany Nov 15 '17 at 23:31