I was using FQL to get all the photos in the user profile pictures album.
Since facebook decided to deprecate FQL in their latest version of graph api, im looking for the easiest and fastest way to get the user profile pictures (all of them)
I was using this FQL:
SELECT object_id, src_big, src_big_height FROM photo WHERE aid in (SELECT aid FROM album WHERE owner = 'XXXX' AND type = 'profile') LIMIT 20"
Any graph method that would get me the equivalent in 1 graph call? (I know i call call for /user/albums and to use the album id later to get the photos, but i don't want to seperate it to 2 calls)
Thanks alot
Ok, the best I could came up was using graph api field expansion:
https://graph.facebook.com/me?fields=albums.limit(1).fields(name,photos.fields(name,picture,source,images))
Im assuming the first album is the profile pictures.
Hope this can help others :)
Related
Facebook's FQL was deprecated after v2.0. The website I'm working on previously had a "Recent photos" feature that populated recent photos using this FQL:
var fql = 'SELECT object_id, aid, images, album_object_id, created, modified, position, caption
FROM photo
WHERE aid in (SELECT aid, owner FROM album WHERE owner = me())
ORDER BY created DESC
LIMIT 59';
I'm trying to figure out a comparable way to do that using the graph api. the /photos endpoint is probably what I want, but I can't figure out if it has a valid order queryparam.
In postman I've been messing around with this:
https://graph.facebook.com/v2.2/10151316456544622/photos?fields=picture,name,source,created_time&limit=20&order=-created_time&debug=all&access_token=CAAL7TZAyo4RUBAOJe4Jgjdt6NZAqcajRghEGdKwraq4X1yZAKjvgXj4xXAZCoyZCkzMO84mTMJ90Vp5CEfJsT1WsoOwif2QZCS00bGqZAVxqmZChMUqKQmNsu2DvZCoY42ZC5fSBAxUuNCqTWg1QZCBZCz5oQx3wcNZCZCPUHOXMu5i5jZCOTGIiPWrAeTlzhFBqkvoZBZAPSJRhlkdxyrKPmpmOqgKrUeD13TdOtKU4ZD
The access_token is of a FB test account, feel free to go nuts. I'm not getting any debug information. There doesn't appear to be anything in the docs about how to change the order of photos.
This example url might not be the best. There's only 7ish public photos for this account, but I will potentially be getting recent photos from accounts with 1000s of photos. I don't want to just get all photos and reverse the list. I want to the most recent 20 photos in one call.
Any ideas? Is there order documentation that I've missed?
There is no direct way to achieve this using the Graph API, but you can use Real Time Updates to get notified about changes to the photos of a user.
I want to show the photos of an album in my app. Using the graph API i am able to filter and page by month, like below, which is great. I loop trough the results and get the photo for each id. Best of all, the GRAPH API also gives me a 'next' and 'previous' paging link. Very useful.
http://graph.facebook.com/[photo-album-id]/photos/?fields=id&limit=6&since=last month
But now i want to retrieve only those ids filter in two ways:
Only retrieve those in which the user is tagged
Only retrieve those in which the user & his/her friends are tagged.
I couldn't find any way to do this, with the graph API. Is there an alternative via FQL, that still has the paging in there?
Last alternative I can think of is program is in FQL, and do the paging myself.
p.s. I am doing this in Javascript currently.
You can retrieve photos the current user is tagged in in a specific album with this FQL call:
select object_id, src, album_object_id from photo where pid in (select pid from photo_tag where subject=me()) and and album_object_id=somenumber
To retrieve photos in which the user's friends are tagged, for a specific album:
select object_id, src, album_object_id from photo where pid in (select pid from photo_tag where subject in (select uid2 FROM friend WHERE uid1 = me())) and album_object_id=somenumber
As far as I know these results will not be paginated. For a detailed take on how to paginate fb queries see the Facebook Developer Blog: How-To: Paging with the Graph API and FQL
After a little play with the Graph Explorer (https://developers.facebook.com/tools/explorer/) I come up with this solution. You can make a call to Graph API as follows
/me?fields=friends.limit(5).fields(photos.limit(5))
The first limit is for how many friends you want to get and the second limit is how many photos you want from each friend.
At the end of the data there already is the next page URL.
I only tested on the explorer but should work.
Hope that helps,
Doruk
I know both the old Facebook REST API and the new Graph API fairly well. Through the graph api and given maximum permissions I can request a user's photos (its my app and my account):
client.Get("/me/photos");
This returns an array of json encoded graph api photos. The only problem is that it's not the total number of photos in the account. I checked this by painstakingly counting my facebook photos AND comparing it against a simple call from the old REST API:
select pid from photo where aid in (select aid from album where owner=me())
(the above from memory, but what I had worked well)
My count and the REST API confirm that the graph API is NOT returning all the photos in the account (I know about paging as well).
Does anyone know why this is? Also, does anyone know how to convert an old REST API pid (photo id) to a new GRAPH API unique ID. It's the only way I can think of to get all the photos.
FQL is still available in the Graph API
https://graph.facebook.com/fql?q=select pid from photo where aid in (select aid from album where owner=me())
Also, there's another property called object_id on the photo fql table which should correspond (if memory serves) to the id in the photo api table
https://developers.facebook.com/docs/reference/fql/photo/
https://developers.facebook.com/docs/reference/api/photo/
Try:
https://www.facebook.com/photo.php?pid=11504724&l=3f088bdde4&id=99984862969
https://graph.facebook.com/fql?q=select object_id from photo where pid="99984862969_11504724"
Response should be:
{
"data": [
{
"object_id": "10151373634447970"
}
]
}
How can I get the facebooks' user cover photo via the PHP SDK?
Thanks in advance.
B.W.
I have tried to loop through the Graph API, but it didn't work because the album was in the second page, and wasn't displayed.
There's no way to get this without looping through the album list - you could specify a higher limit in the request for the initial list of albums if you really need to do this without paginating through the albums
I've read all of the Graph API document but nowhere mention to the photo uploaded by user.
I've found that for video uploaded by user, I can use: https://graph.facebook.com/me/videos/uploaded
But what about photo? Is it possible?
Thanks, and sorry for my bad English (cause English is not my native language :) )
I'm not sure how you couldn't find it.
Anyway you need to query two tables to get what you want, the album and photo FQL tables:
SELECT pid
FROM photo
WHERE aid IN (
SELECT aid
FROM album
WHERE owner=me()
)
You can get whatever you want from the photo table obviously. Also you may change me() to a user id.
I suppose that you need the user_photos or friends_photos permissions depending on your needs.