Why doesn't the Graph API return the newest photos a user has been tagged in? - facebook

About a dozen users have complained that my app that fetches photos they are tagged in is not fetching the most recent photos... it is a simple call.
http://graph.facebook.com/me/photos
Is there any way to get the newest photos? Some sort of Order By? Or is there some kind of delay between tags and access via the API?
Any help would be appreciated!

I've seen some goofy stuff going on with the Open Graph API over the last week where objects that belong to a record are not getting returned with a valid API call. My issue went away on its own this weekend.
There is some delay in the best case between when an item gets tagged and it shows up on all the FB servers. The server that is serving your user's page to them will be different than the one serving the Graph API response. In my experience it is usually less than 30 mins, for the update but I've seen it take up to 6 hours.
As far as I can tell, you need to use an FQL call to explicitly order the results you get back.

You can get a list of photos with tags ordered by time by using this FQL query:
SELECT subject, object_id, created FROM photo_tag WHERE subject = USER_ID
where subject is the user id of the user who was tagged, object id is the id of the photo object, created is the creation time (as Unix timestamp), and photo_tag is the FQL table. This will return a list ordered by time with newest first.
From there, you can get the photo url using the object_id like this:
SELECT src, src_big, src_small FROM photo WHERE object_id = OBJECT_ID
which will give you urls to the photo in 3 differen sizes. This uses the FQL photo table.

Related

Get recent photos from the Facebook v2.1+ graph api

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.

How FB graph api 2.0 replace FQL like this?

As we all know, facebook release the big updated on 30th April,2014. One of the changes log or alert is, FQL will not be available for the next version.
I tried and tried hard to replace and existing FQL using the graph API in order to get the same result. However, I failed.
One of the example goes like this:
SELECT src_big, caption, object_id, owner, images, created
FROM photo WHERE aid IN
(SELECT aid FROM album WHERE
owner IN (page_id1, page_id2, page_id3, page_id4)
AND type!='profile'
ORDER BY modified DESC)
AND created < 1398172643
ORDER BY created DESC
LIMIT 16
This example is to get some public photos from pages.
Anyone can tell me, how can I do that with Open Graph?

Facebook Graph API: Get all posts from all the pages the user likes

I want to get all the posts from all the pages from the user /me/home feed.
Right now Facebook is deciding for the user what posts will get to the feed and which ones will not.
For example, if the user is subscribed (likes) 100 pages and all 100 of them posts an update the user feed will not show all 100 of them, only a portion of updates that it thinks important. Neither the API.
Is it possible to get all updates using the Graph api (like a regular timeline)?
You can try FQL, for example:
{"query1":"SELECT type,post_id,created_time,actor_id,target_id,message,attachment.media,attachment.caption,attachment.name,attachment.description,attachment.fb_checkin,likes.count,likes.user_likes,likes.can_like,comment_info,description FROM stream WHERE filter_key='pp' AND created_time<now() ORDER BY created_time DESC","query2":"SELECT id,name,pic FROM profile WHERE id IN (SELECT actor_id,target_id FROM #query1)"}
The keyword was filter_key='pp', means that you want to get all page's news feed.
I have no idea it will include ALL of 100 pages on real time, however this should be enough to achieve your goal. One more point, news feed have 1 week limitation, means that you cannot query older than 1 week's news feed.
Update:
https://graph.facebook.com/me/home?filter=pp is alternative way if you don't want to use FQL.
Use the following FQL in your https request to get the list of all likes paginated
SELECT src_big, src_small, owner,caption FROM photo WHERE object_id IN (SELECT object_id FROM like WHERE user_id == me() LIMIT 10 OFFSET 8 )

How to get all people who liked Facebook post?

I have FB post
I can click "77 people like this" and get all people I needed.
Question: is there way to get these people by FB API ?
PS I want to get 3 random names from these list so I need to have these people in JSON format
It's easy to do with FQL. This gets you three random ids of people who liked this event
SELECT user_id FROM like WHERE object_id = 336638873112346 ORDER BY rand() LIMIT 3
If you wanted to get their names instead, you'd rewrite the query like this:
SELECT uid, name, username FROM user WHERE uid IN
(SELECT user_id FROM like WHERE object_id = 336638873112346 ORDER BY rand() LIMIT 3)
I'm one of the co-founders of Kither, a platform for checking all of your Facebook stats. We have added many features which requires to fetch all of our user's posts likes.
As of August 6, 2016, FQL is deprecated.
Facebook's Graph API's still available and you can call https://graph.facebook.com/{api-version}/{post-id}/likes to get likes on posts. But remember, Facebook uses pagination on likes if there are more than 1,000 of them.
Now, In this case you'll need to call the next page url.
You'll need to call the next url unless you've got all the likes. (you won't find any next field if there are no more likes)
To get how many people have liked that post (i.e. count), you don't need to page through results. You can simply use https://graph.facebook.com/{api-version}/{post-id}/likes?summary=true and you'll get an extra field containing all likes' summary, including their count.
Same can be done with comments and recently added, reactions.

Using the Facebook Graphi API, how can I retrieve paginated photos in which my friends are tagged from a specific album?

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