Getting images from facebook group album - facebook

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.

Related

Instagram API response with users not in caption

I want to know what users are tagged in a photo on Instagram, who don't appear in the caption.
Anyone know if this is possible? That is, does the response contain users that are tagged, but that are not physically in the caption text?
https://www.instagram.com/developer/endpoints/tags/
The property you probably want is called users_in_photo. It is an array which contains an array of user objects who've been tagged in the photo. It also contains the geometric coordinates in the photo that the user has been "tagged" at.
Here is an example response using the /media/MEDIA_ID endpoint:
Endpoint Documentation -> https://www.instagram.com/developer/endpoints/media/#get_media
{
"data": {
"users_in_photo": [{
"user": {
"username": "kevin",
"full_name": "Kevin S",
"id": "3",
"profile_picture": "..."
},
"position": {
"x": 0.315,
"y": 0.9111
}
}],
// rest of object...
}
}
I think what you are looking for are username mentions in captions and comments, API does not return this list in API, you will have to search for #usernames in the caption string.
You will have to make a separate API call to get the comments in post (u can only get latest 120), and do a manual string search in each of the comments.
users_in_photo in API response will have an array of users that are actually tagged on photo, not username mentions

How to get photo Like Info from graph explorer?

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.

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

FQL query of photos for Facebook users with large numbers of photos

I need to get photos of an FB user sorted by likes.
I ran this FQL query via Facebook JavaScript SDK to get them:
SELECT object_id, src_big, src_big_width, src_big_height, link, like_info, caption, created
FROM photo
WHERE owner = MANY_PICS_USER_ID ORDER BY like_info DESC LIMIT 10
The query fails for users with more than 3000 photos. Turns out there are a lot of those users. Related Facebook bug is here http://developers.facebook.com/bugs/438568326189781
As a note: removing "ORDER BY like_info" makes query work, but there is no easy way for me to get those pictures, sorted by likes
To reproduce:
Pick a FB friend with at least 3000 photos, get their user Id, and run the above query (replacing MANY_PICS_USER_ID) in API GRAPH EXPLORER.
What is the best workaround? Or, can you suggest the easiest light-weight Open Graph solution?
To sort photos by likes you need the following:
Run the query which gives first 100 results (replace me with user id):
http://graph.facebook.com/me/photos?fields=id,source,likes&limit=100
Which return the following data structure:
"data": [
{
"id": "1234567890",
"source": "http://photo.url.in.facebook.cdn.com/",
"created_time": "2012-09-13T22:52:34+0000",
"likes": {
"data": [
{
"id": "1234567890",
"name": "Full Name"
},
.....
"paging": {
"next": "https://graph.facebook.com/1234567890/likes?limit=25&offset=25"
}
}
},
{
"id": "312323232323",
"source": "PICTURE_URL",
"created_time": "2012-09-12T20:54:27+0000",
"likes": {
"data": [..]
}
},
....
"paging": {
"previous": "http://PREVIOUS_URL?fields=id,source,name,height,width,link,likes&limit=100&since=123456",
"next": "http://NEXT_URL?fields=id,source,name,height,width,link,likes&limit=100&until=234567"
}
If total number of pictures is more than 100, run all next queries,
from the "next" link until the num of pics will be less then 100.
For every picture you need to count total number of likes. If the
number of likes is more than 25, run extra query from
likes.paging.next until number of likes will be < 25 and get the
total quantity.
Sort all those pics by number of likes.
So for the user with 3000 pics it will be in total 30 calls + extra calls for each picture with more than 25 likes.