Get all photos the user is tagged in on Facebook - facebook

I'm trying to fetch all the images I'm tagged in on Facebook.
It's working almost as it should, I just got one problem.
If I'm tagged in the post, but not tagged on the image, it doesn't show up in the output.
Any ideas why?
Here is my code:
SELECT pid, src_big, link, album_object_id, object_id, place_id, aid, created
FROM photo
WHERE pid IN (SELECT pid, object_id FROM photo_tag WHERE subject = me());

On-picture tags are not the same as tags in the description (post).
There are three FQL tables to get the content where a user has been tagged:
photo_tag to get tags on photos,
stream_tag to get tags on posts,
video_tag to get tags on videos.
You used the first one but you also need the second one. Similarly to your photo tags request, you will then have to use the stream table.

Related

FQL: How to get other photos belonging to the same post?

SELECT created_time, like_info, share_count, message, attachment FROM stream WHERE post_id='119757088035616_862221027122548'
With this FQL-Query, i'm getting several information about one post inside the stream of a facebook-page. However, that single post could also be a single image inside an album of photos. Is there a way to catch every photo belonging to a post (which would be a new album, in this case)?
To get all photos of the album the posted photo is in, try this FQL query:
select pid, aid, created, src from photo where aid in (SELECT attachment.media.photo.aid FROM stream WHERE post_id='119757088035616_862221027122548')
In case you just want the photo info, use this for example:
select pid, aid, created, src from photo where pid in (SELECT attachment.fb_object_id FROM stream WHERE post_id='119757088035616_862221027122548')

Trunc/empty photo fids by FQL

I want to get all photo fids albums.
For example, I have albums and my friends of course have albums.
I can get album fids by:
SELECT object_id FROM album WHERE owner IN (...)
It worked. Now I want get photo fid this albums:
SELECT object_id from photo WHERE album_object_id IN (albumFid1,albumFid2)
Now I can get errors (empty or truncate data). If I use only one param with IN(), it's all ok. I see photo fids. But if I use several album fids, I starting get incorrect data. No matter who is albums owner.
I try simple test: get all photo fids of all my albums:
fql?q={"albums":"SELECT object_id FROM album WHERE owner = me()", "photos":"SELECT object_id from photo WHERE album_object_id IN (SELECT object_id FROM #albums)"}
It worked. Also worked if I use any my friend. But if I use several users - and album fids of different users, now get magic results.
I open bug at https://developers.facebook.com/bugs/445214712163793. But not have any response. In bug I use situation with two albums (me and my friend). I get diff results then use diff album fids order with IN().
Interested, that two weeks ago all worked correct.
I find only one solution: use FQL multi query. Each query - one user albums.

Facebook Graph - getting my pictures

I'm looking for the fastest way to get all the pictures I'm tagged in with someone specific.
As for now I need to check "my photos" then "the other someone's photos" and then photos in albums of all my friends.
it takes forever.
I need a way (I guess it's an FQL request) to get all the photos me and a specific friend are tagged in together?
Getting some of the photos easy to do with an FQL Query:
SELECT object_id, src, owner, caption, created
FROM photo
WHERE object_id IN (SELECT object_id FROM photo_tag WHERE subject = me())
AND object_id IN (SELECT object_id FROM photo_tag WHERE subject = 'MY_FRIENDS_ID')
(In this example MY_FRIENDS_ID could also be an event id or a group id)
Facebook has limits on the number of objects returned by an FQL query. To get all of the items, you'll have to write a script that appends AND created < {OLDEST_DATE_RETURNED_BY_LAST_QUERY} to your FQL and repeats the query until no data is returned.
Demo query here of photos you are tagged in: https://developers.facebook.com/tools/explorer?method=GET&path=fql%3Fq%3DSELECT%20object_id%2C%20src%2C%20owner%2C%20caption%2C%20created%20FROM%20photo%20WHERE%20object_id%20IN%20(SELECT%20object_id%20FROM%20photo_tag%20WHERE%20subject%20%3D%20me())

Fql, fetching "photos of me"

In my facebook page, when someone who's not the admin posts a photo, it goes into an album called "photos of me" that is different from other albums made by me.
It has no 'aid'... its url is:
http://www.facebook.com/photo.php?fbid=1760432628996&set=o.373236069382570&type=1&permPage=1
Photos are public, you can see them even if you're not registered on facebook.
I'm able to fetch photos in other albums of my page using this FQL:
SELECT pid, src, caption FROM photo WHERE aid = 'MY_ALBUM_ID' ORDER BY created DESC
But I can't fetch photos in "photos of me" album because there's not 'aid'. I tried to query the stream but I got only pictures I posted on my wall.
Could someone paste me the correct FQL to fetch photos on the album above?
These are photos you've been tagged in, so they aren't your photos. That's why they don't show up in any of your albums.
This query gets them:
SELECT pid, object_id, src, caption FROM photo WHERE object_id IN
(SELECT object_id FROM photo_tag WHERE subject='373236069382570')
According to the developer reference, FB prefers object_id to pid now. You might want to work with object_ids to prevent breaking your code if FB deprecates pid.

get feed when some one tagged user in photo FQL

I want feed when some one tagged user in photo currently i am only able to get that photo but not feed with comments and likes as below
select object_id,src from photo where pid in (SELECT pid FROM photo_tag WHERE subject=me())
FYI currently i need to get first all photos then have to check whether it is photo of user himself or tagged by someone. so it seem lil bit complex..
thanks in advance
i sorted out finally...Through below FQL you can get with type=65
SELECT type,post_id, actor_id, message,comments,attachment,description,created_time,updated_time FROM stream WHERE source_id =me()