23

I've been scouring the docs for a while now and can't seem to find a way to accomplish this. The information is available publicly (on a facebook page ... the link says "View all # shares") but I can't seem to find a way to access this info either via FQL or the graph API.

I know I can get a list of likes for a given post:

https://graph.facebook.com/87236249496_134765166623967/likes

The goal is to get a list of people who've shared -- but there doesn't seem to be the same sort of thing for shares. Am I missing something?

Will
  • 5,370
  • 9
  • 35
  • 48
  • http://www.facebook.com/permalink.php?story_fbid=134765166623967&id=87236249496 how can you see it if no one shared it? – Dejan Marjanović Oct 13 '11 at 00:23
  • @webarto I was not refering to *that* particular post -- i was showing an example of how you can easily get a list of people who liked a post. I imagine there's a way to get similar share information, but after 90 minutes of searching I came here. – Will Oct 13 '11 at 00:24
  • I'll post answer in 5 minutes... – Dejan Marjanović Oct 13 '11 at 00:33
  • Ive just read through every table in FQL -- I'm beginning to think there is no solution, so if you have one in 5 minutes I'll be quite pleasantly surprised. – Will Oct 13 '11 at 00:36
  • I'll give you a hint, won't work 100%... you have to be logged in via PHP. Probably no API yet, since mobile version doesn't even have that option. – Dejan Marjanović Oct 13 '11 at 00:38

5 Answers5

15

You can do it via "graph.facebook.com/OBJECT_ID/sharedposts" connection:

enter image description here

I figure it out this connection via metadata=1 parameter:

enter image description here

林果皞
  • 7,539
  • 3
  • 55
  • 70
  • This I believe is the more appropriate answer given its using the API. – Pat Feb 21 '14 at 18:15
  • 5
    Great! BTW you also need ```read_stream``` permission. I've stuck on that. Without it you will get only empty response. – ruX Sep 22 '14 at 12:42
  • Hi @ruX, how did you manage to get the `read_stream` permission ? It seems almost impossible with their review standards. – Tanzaho Feb 11 '16 at 09:05
  • Works if you use the v2.3 API – Frondor Aug 03 '16 at 09:20
  • @Frondor v2.3 also empty, no result been displayed.It only return { "created_time": "2016-10-17T10:10:46+0000", "id": "123456471212" } – Shiro Oct 20 '16 at 02:27
10

Go to... http://www.facebook.com/ajax/shares/view/?target_fbid=10154612868272801&__a=1

10154612868272801 is Facebook story ID, __a stands for asynchronous.

You will see large amount of text/JSON, it is basically HTML & JS for little popup window. There is portion of text like hovercard.php?id=# where # is Facebook user ID, using preg_match_all you then get all of the user ID's who shared that post.

Eg: 100000541151971 (Eric) and 9204448 (Courtney)...

Unfortunately, you must be logged into Facebook to do first step, figure it out :)

Dejan Marjanović
  • 19,244
  • 7
  • 52
  • 66
  • I've been meandering down that road on my own at this point -- but I'm having a difficult time believing that public information isn't available via the API in some way. Relying on this method is just asking to have it broken on a regular basis =\ but may be the only option. +1 Being "logged into facebook" via curl will be a pain in the arse, but doable. – Will Oct 13 '11 at 00:55
  • @Will, I know, there are lots of "wanted" API calls that doesn't exist even it has been requested numerous times, like I've said, this isn't implemented on mobile version, maybe after that they will make API method. Until then, happy hacking :) – Dejan Marjanović Oct 13 '11 at 01:02
  • I ended up going this way ... and it feels dirty. May 2012 and still using it, it gets broken regularly by facebook changes. Blah ... – Will May 15 '12 at 15:42
  • 4
    Update: You can do it via "graph.facebook.com/OBJECT_ID/sharedposts" connection. – 林果皞 May 23 '13 at 19:23
  • @林果皞, it seems to work for me to, but can't see it in the docs... maybe you could post an answer to this question. – billy Jan 10 '14 at 16:08
  • @billy Ok. I've post this answer. – 林果皞 Jan 10 '14 at 17:28
2

I think you can get the share_count from stream table by FQL query just like


SELECT type, source_id, share_count, permalink, description, post_id, actor_id, target_id, message , share_count 
FROM stream
WHERE filter_key = 'others' and post_id = '87236249496_134765166623967'

you can test it https://developers.facebook.com/tools/explorer/

Note: you have to take the read_stream permissions as explained here

HMagdy
  • 3,029
  • 33
  • 54
2

Tye this link: https://graph.facebook.com/134765166623967/sharedposts (with a valid access_token)

The id in the link is the wallpost id (87236249496_134765166623967) minus the page id (87236249496) and minus the underscore.

You'll also need the read_stream permission

Steven Delrue
  • 423
  • 5
  • 8
  • 1
    It is not giving information about shares, I can retrieve shares count and all info about likes and comments, but not about shares – emir Jan 03 '17 at 16:04
1

I know you're looking to get at shares through the post_id, but can you settle for finding shares by page_id instead of post_id?

If you can, then you can use the following FQL to get the data you're looking for.

SELECT via_id, created_time, owner_comment
FROM link
WHERE owner = me()

You can then compare via_id against the posts author (page ID) to determine if this share came from the post author in question.

Unfortunately, there seems to be a bug with the data return where some of the via_ids come back as 0. There is a ticket in with Facebook which, at the time of this post, has been open for three weeks at medium priority. I have no idea if this issue is specific to my app or affects everyone, but that query might get you what you want.