How to get people who have shared specific FB post? - facebook

It's easy to get people who have liked post: https://graph.facebook.com/19292868552_10150189643478553/likes
How can I get people who have shared this post ?

Using the Graph Explorer with a post that has shares:
https://graph.facebook.com/20531316728_10151733211311729?fields=shares
The output is:
{
"shares": {
"count": 1806
},
"id": "20531316728_10151733211311729",
"created_time": "2013-02-10T12:59:25+0000"
}
Of course if you remove the fields parameter you see all the fields associated with that object.
EDIT: The post on Facebook - https://www.facebook.com/photo.php?fbid=10151733211231729&set=a.376995711728.190761.20531316728&type=1

Related

Facebook Graph API: Check if user has liked a specific post

I am rather new to Facebook Graph API and I'm trying to find out if a user has liked a specific post.
Right now, in order to achieve this, I get all the likes for that post and then I iterate through them to find a match. But this procedure requires a lot of requests when the number of likes is too high, as the maximum number of likes per request appears to be 100.
Is there any better way to check if the user has liked the post?
Request the summary of the likes (post_id?fields=likes.limit(0).summary(1)), then you will get a data structure that looks like this:
{
"likes": {
"data": [
],
"summary": {
"total_count": 1,
"can_like": true,
"has_liked": false
}
},
"id": "…"
}
The properties can_like and has_liked reflect the values for the user who’s access token you used to make the request.
UPDATE
The latest version of Graph API today is v2.8. In this version you can get the reactions also. It is better to use reactions than likes as reactions also includes the Love, WOW and HAHA etc reactions which likes does not.
You can add the field for reactions's summary instead of likes's summary as below
fields=reactions.limit(0).summary(true)
Using this you will get the reactions summary as below
"reactions": {
"data": [
],
"summary": {
"total_count": 6,
"viewer_reaction": "LOVE"
}
}, ......
Notice the "viewer_reaction": "LOVE" which means you have given a reaction to the post which is LOVE. It's value could be any one of LIKE, LOVE, HAHA, WOW, SAD, ANGRY, NONE. The NONE means you have not liked the post.

Facebook API not working sometime for some URL

I'm getting number of shares and comment of blog posts using facebook graph api for my blog, but sometimes it do not return shares and comment.
Following URL is not giving number of share and comments.
http://graph.facebook.com/?id=http://www.lehedonist.com/jeans-is-the-new-whiskey-2001
BUT it is working for this URL:
Example: http://graph.facebook.com/?id=http://www.lehedonist.com/spring-slam-fashion-war-ss16-1965
I somehow wonder why it's even working to request these URLs without an access token to be honest.
See
https://developers.facebook.com/docs/graph-api/reference/v2.5/url
It only gives a result if there no version info in the URL. To do this in the v2.5 way properly, you'd have to use
https://graph.facebook.com/v2.5/?access_token={access_token}&fields=id,og_object,share&id=http://www.lehedonist.com/spring-slam-fashion-war-ss16-1965
where {access_token} is an actual access token.
Results will look like
{
"id": "http://www.lehedonist.com/spring-slam-fashion-war-ss16-1965",
"og_object": {
"id": "987675524635070",
"description": "Not your usual fashion post, we decode styles best suited to your personality and what should you be sporting next summer",
"title": "Spring Summer 16 fashion: The clash of fashion personalities",
"type": "article",
"updated_time": "2015-10-08T11:24:32+0000",
"url": "http://www.lehedonist.com/spring-slam-fashion-war-ss16-1965"
},
"share": {
"comment_count": 2,
"share_count": 81
}
}

How to query facebook with FQL to get usernames who liked and commented on a post or a photo

Ok what i want to do is simple but i am not sure it can be done or not
Here my post and image that i want to query
Original share image :
https://www.facebook.com/MonsterMMORPG/photos/a.551985868170404.1073741825.198765706825757/694573437244979/?type=1
The reshare of the image
https://www.facebook.com/MonsterMMORPG/posts/699889243380065
Now i want to get people who liked image and post and also commented on them
I am trying to get userids of who liked via FQL like below but it returns nothing
SELECT user_id FROM like WHERE post_id=699889243380065
I am doing this at graph api explorer panel here screenshot
first image works second fails
You can use Facebook-graph-api to get your list of likes, as follows:
https://graph.facebook.com/v2.0/699889243380065/likes
(with valid tokens of course)
You'll receive the following list:
{
"data": [
{
"id": "xxx",
"name": "xxx"
},
{
"id": "xxx",
"name": "xxx"
},
etc
To get list of comments via graph-api:
https://graph.facebook.com/v2.0/699889243380065/comments

Facebook Likes for multiple pages in a domain

The problem to solve:
Imagine I have a domain and corresponding web site at http://my-awesome-site
On this site I have 10,000 pages.
Each page has a Facebook Like button.
How do I retrieve the number of likes per page from the Facebook Graph?
It's possible to look up the total number of likes per URL using a simple GET request (examples: google.com, google.com/reader, news.google.com). But is it possible to get a similar list for an entire domain, broken down by page? Something with results like:
{
"id": "http://my-awesome-site/",
"shares": 12345
},
{
"id": "http://my-awesome-site/page1.html",
"shares": 5678
},
....
{
"id": "http://my-awesome-site/page10000.html",
"shares": 9012
}
You can do this also via facebook graph
seperate ids with commas
https://graph.facebook.com/?ids=http://techcrunch.com,http://mashable.com
the result will be a json, shown below
{
"http://mashable.com": {
"id": "http://mashable.com",
"shares": 14436
},
"http://techcrunch.com": {
"id": "http://techcrunch.com",
"shares": 2144
}
}
I think that the best you can do is (using the link_stat table):
SELECT url, share_count
FROM link_stat
WHERE url IN ("http://my-awesome-site/", "http://my-awesome-site/page1.html"...)
But if you have 10,000 pages you'll have to break it into multiple requests.
You can however use the Batch Requests api to then combine some requests.
That solution should lower the amount of http requests considerably if that is what you're after.

How do I get the permalink of a specific Facebook Social Plugin Comment through the Graph API?

Consider the following piece of dummy data returned from the Graph API for Facebook's Commenting Social Plugin:
{
"id": "387539086359_14842802",
"from": {
"name": "Manja Elis",
"id": "1168990251"
},
"message": "http://www.facebook.com/pages/Manja-Elis/151029671610040",
"created_time": "2010-11-24T07:06:06+0000",
"comments": {
"data": [
{
"id": "494442921359",
"from": {
"name": "J Reigy T II",
"id": "100001234540335"
},
"message": "~ www.jareta.name ~",
"created_time": "2011-01-30T00:04:30+0000"
}
],
"count": 1
}
}
How can I generate the permalink to this specific comment so that it can be bumped to the top of the discussion?
I know that the first id# "387539086359_14842802" is the ID of the comment thread as a whole, but now I need the specific ID of the actual first comment so that I can properly link to it. The problem is, that 3rd piece of ID information is nowhere to be found.
What I find funny is that the reply comment with id# "494442921359" is the correct ID for that reply, but there is no equivalent offered for the original post - why??? Worse yet, Facebook ignores links to any comments that aren't the first in a new sub-thread so linking to the reply instead is useless to me.
So to clarify:
Comment id of first post in the thread is : 387539086359_14842802_????
Comment id of the reply to this post would be: 387539086359_14842802_494442921359 but unfortunately FB ignores reply IDs so it is useless to me.
Can anyone tell me how I programatically get this ???? ID for permalink generation purposes?