How to get photo Like Info from graph explorer? - facebook

Can any body tell me how to get the photo Like Info from graph explorer?I tried this fql query
select like_info from photo where object_id=PHOTO ID
Using this query This photo Id-10152460216420695 gives me result
{
"data": [
{
"like_info": {
"can_like": true,
"like_count": 2118,
"user_likes": false
}
}
]
}
But this photo Id-551468638224054 gives me result
{
"data": [
]
}
This two photo are the public and both have more than 1 like.So why the last one can not give me the right result?Waiting for your help...

You can use :
select like_info from photo where object_id="PHOTO ID"
If it fails than it means The photo is invisible for graph api.

One of those photos may not be available via the API due to privacy settings. Even though a photo is public on Facebook itself, there may be other reasons why the piece of content isn't emitted via the API.

Related

Retrieve Facebook reviews likes via Graph API

I am trying to retrieve some reviews data from Graph API, including comments, sub-comments, etc.
I can get like_count on comments using the endpoint with these parameters:
{page-id}/ratings?fields=open_graph_story{comments{like_count}}
Or the same thing with sub-comments:
{page-id}/ratings?fields=open_graph_story{comments{comments{like_count}}}
But I can't seem to find how to get them for the review itself.
I tried this:
{page-id}/ratings?fields=open_graph_story,like_count
And this (which throws an error):
{page-id}/ratings?fields=open_graph_story{like_count}
Just to be clear: in this question I separated the calls for likes on comments/sub-comments, but in reality, I'm getting all the data in a single call like this:
{page-id}/ratings?access_token={access-token}&fields=open_graph_story{comments{created_time,from,message,comments{created_time,from,message,like_count,user_likes},like_count,user_likes}},rating,review_text,created_time,reviewer
try
graph.facebook.com/open_graph_story_id?fields=likes
should return a payload structured similar to below
{
"likes": {
"data": [
],
"can_like": true,
"count": 0,
"user_likes": false
},
"id": "open_graph_story_id"
}

How to get Facebook page links + like count for each?

How do I get the links posted in a Facebook page AND the # of likes that link got without making extra calls?
Right now I am making this call, and it gives me all the posts that are links, posted in a Facebook page. How do I get the like count for each post? I simply want to know how many people liked that post.
https://graph.facebook.com/#{facebookId}/links?access_token=TOKEN&limit=20
To get the likes count for each post that is a link, the following query:
https://graph.facebook.com/#{facebookId}/links?fields=likes.limit(1).summary(true)&access_token=TOKEN&limit=20
gives you a response like this:
{
"data": [
{
"id":
"created_time:"
"likes": {
...
"summary": {
"total_count": 23
}
}
},
{
...
}
]
}
The total_count value is what you want.

Getting images from facebook group album

I'm having a problem with the Graph API / FQL and I have searched however no solution has come up.
I'm unable to retrieve photos from a group album.
I can retrieve a lot of information regarding that group album which indicates that a group album is just a regular album:
SELECT description, owner, photo_count, type, like_info,
cover_pid, comment_info FROM album WHERE object_id = '1382173765340875'
{
"data": [
{
"description": "10 Desafio Outros!!!",
"owner": 1455136613,
"photo_count": 8,
"type": "normal",
"like_info": {
"can_like": true,
"like_count": 1,
"user_likes": true
},
"cover_pid": "6249764165120950711",
"comment_info": {
"can_comment": true,
"comment_count": 0,
"comment_order": "chronological"
}
}
]
}
Calling "/1382086785349573" gives me the group information.
Calling "/1382086785349573/albums" gives me a list of all the albums in the group including ID, album name and even correct count.
but "albumid/photos" where album ID was retrieved from previous call returns an empty array
Also "/groupid/photos" returns an empty data[] array.
Can anyone tell me why this happens? I already removed my app from sandbox mode but still showing the same problem.
I don't understand why it can retrieve album information including items count and etc but not the photos in it.
Thanks in advance for any help.

Missing Photos from Timeline Photos album

I'm using Facebook Graph API to get all the photos of a user graphPath: me/albums and find something weird with Timeline Photos album.
Photos exist in Timeline album on Facebook, but not returned from API call graphPath/{timeline_photos_album_id}/photos, or they are returned with lower number of photos.
What is the problem?
Logs:
Calling for albums graphPath: me/albums:
.....
{
"can_upload" = 0;
count = 3; !!!!!!!!!!!
"created_time" = "2013-06-18T10:43:27+0000";
description = cool;
from = {
id = 100006100533891;
name = "Mike Mike";
};
id = 1387760311437307;
link = "https://www.facebook.com/album.php?
fbid=1387760311437307&id=100006100533891&aid=1073741829";
name = "Timeline Photos";
privacy = everyone;
type = wall;
"updated_time" = "2013-06-18T10:47:53+0000”;
},
.....
Calling for album photos graphPath/{timeline_photos_album_id}/photos:
{
data = (
);
}
Unfortunately "it is not a bug, it is by design".
I tried the following (with "user_photos" permission) and it works:
Fetch the album photo count for my user:
https://graph.facebook.com/me/albums?fields=id,count&access_token={access_token}
The result is
{
"data": [
{
"id": "{album_id}",
"count": 161,
"created_time": "2010-11-05T15:41:42+0000"
},
....
}
Then query for the photos of this album:
https://graph.facebook.com/{album_id}/photos?fields=id&limit=500&access_token={access_token}
The result is
{
"data": [
{
"id": "{photo_id1}",
"created_time": "2013-12-29T09:59:52+0000"
},
{
"id": "{photo_id2}",
"created_time": "2013-12-17T10:40:26+0000"
},
...
}
I count the correct number of 161 ids in the result. So everything seems to work fine.
You can also test this via FQL:
https://graph.facebook.com/fql?q=select+pid+from+photo+where+album_object_id+=+{album_id}+limit+1000&access_token={access_token}
there have been changes in the FB API recently, did you try to add the fields you want to get back in the result from the API? In the past, API always returned "standard fields", newest you always have to provide a list of fields of what you want to have back in the result such as ....fields=name,id...
I think you are missing the user_photos permission in the Access Token. The end point:
/{timeline_photos_album_id}/photos is working perfectly fine for me when I tried it using the Graph API Explorer to retrieve photos from my Timeline photos album. And, I don't think that it is necessary to provide the fields.
I'll suggest you should try the same using the Graph API Explorer. Just press the Get Access Token button on the top right and check the user_photos permission to test your request.
In case you are getting lesser results, you can try your query using pagination options limit and offset. This sometimes returns more results as compare to normal(nothing about this on docs, just my personal experience). Something like:
{timeline_photo_album_id}/photos?limit=500&offset=0
But again, as you pointed out, there are strange things going on with the API. Take a look at this article. This article refers to it as an expected behavior of the API!

FaceBook API for friends count

There is the question about fetching count of user friends via FaceBook API.
I want to get the number of friends only have USER_ID of the any facebook user. As I know I can get it using FQL like:
SELECT friend_count FROM user WHERE uid = X
But for some users this value is null or there is no value. Please advice is there another way to get this value?
That user might be keeping that information private. In that case, you cannot fetch that information.
You just check the following link. You need to generate token (by clicking on Get Token you will get it) with data you want from facebook API, need to select friends option to get the friend count.
https://developers.facebook.com/tools/explorer/?method=GET&path=me%3Ffields%3Did%2Cname%2Cfriends&version=v2.8
FB.api(
'/me',
'GET',
{"fields":"id,name,friends,link,email,gender,picture,first_name,last_name,cover"},
function(response) {
// Insert your code here
}
);
after executing this you will get this in response as
{
"id": "XXXXXXXXXX",
"name": "Test test",
"friends": {
"data": [
],
"summary": {
"total_count": 14
}
}
}
total_count will be your friend count