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

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

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 Real-Time updates: comment on post vs comment on album

Status entry comment:
{"object":"page","entry":[{"id":"106182246249179","time":1386582683,"changes":[{"field":"feed","value":{"item":"comment","verb":"add","comment_id":"185457974988272_294727","parent_id":185457974988272,"sender_id":106182246249179,"created_time":1386582683}}]}]}
Album comment:
{"object":"page","entry":[{"id":"106182246249179","time":1386581446,"changes":[{"field":"feed","value":{"item":"comment","verb":"add","comment_id":"185444231656313_190183","parent_id":185444231656313,"sender_id":100006218707108,"created_time":1386581446}}]}]}
They seem impossible to distinguish. However, the first one's real post id is pageid_parentid = 106182246249179_185457974988272. If you try to do the same thing with the album comment to get the feed from the stream FQL table, you won't get anything (or an exception with graph api).
Has anyone found a way to distinguish somehow between the two?
Yes.
First you need the object_id
object_id=pageid_parentid
Make this api call with the object id:
GET https://graph.facebook.com/v2.9/{object-id}?fields=type,status_type&access_token=token
The response should look something like this if the parent is a post:
{
"type": "status",
"id": "106182246249179_185457974988272"
}
If it's an album, it will look like this:
{
"type": "photo",
"id": "106182246249179_185457974988272"
}

How to get people who have shared specific FB post?

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

How to get the right Data to an external URL and the right ID through the API?

is there a possibility to get more informations to a specific url e.g. preview image, title and short description through the open graph? If you do something like this, you only get the "shares" //graph.facebook.com/http://www.google.de
It's a bit confusing, when I get the ID via FQL through the object_url Table I get a different ID to the ID I get from the Debugger.
Getting the ID:
//graph.facebook.com/fql?q=SELECT%20url,id,type,site%20FROM%20object_url%20WHERE%20url%20=%20%22http://google.de%22
Result: "id": 6319338796</pre>
Trying to get the Data with that ID failed (acces token needed)
//graph.facebook.com/6319338796/
"message": "An access token is required to request this resource."
Get the ID with the Debugger:
//developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Fgoogle.de
Getting the Result from ID 438699604740 (no problem):
//graph.facebook.com/438699604740
{
"url": "http://www.google.de/",
"type": "website",
"title": "Google",
"image": [{"url": "http://www.google.de/images/google_favicon_128.png"}
],
"updated_time": "2012-12-19T15:26:32+0000",
"id": "438699604740"
}
I am just wondering, why there are two different object IDs for the same URL and why do I need for the one an acces_token and not for the other?
The question is, how to get the right Data and the right ID throug the API? Or are there any restrictions to get these Data from a URL?
Thanks for help!

Facebook Graph API retrieving friends' images

I'm trying to get all the ids of all my friends along with their profile image. I'm using https://graph.facebook.com/me/friends?fields=picture&access_token=[myToken]
I'm getting this returned:
{
"data": [
{
"id": "xxx",
"picture": "http://profile.ak.fbcdn.net/hprofile-ak-snc4/xxx_q.jpg"
}
The picture url that returns is for a really small image. How can I get a larger image?
Recommended
According to Doc (section "Pictures"), url of profile's photos can be built with the user id
For example, assuming user id is in $id :
"http://graph.facebook.com/$id/picture?type=square"
"http://graph.facebook.com/$id/picture?type=small"
"http://graph.facebook.com/$id/picture?type=normal"
"http://graph.facebook.com/$id/picture?type=large"
Hack
http://profile.ak.fbcdn.net/hprofile-ak-snc4/xxx_q.jpg
You can replace the q parameter with s or b
:)