user2469227
user2469227

Reputation:

Get Share Count of Public Video with FB API v2.5

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?

Upvotes: 1

Views: 1941

Answers (1)

inbarda
inbarda

Reputation: 26

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  

Upvotes: 1

Related Questions