Facebook Graph - getting my pictures - facebook

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())

Related

How to Get Share count of a picture while it says share_count is not a member of photo table

I am using this query and trying to get share count of each pic but it returns an error.
SELECT link, comment_info, like_info, created, pid, src_big FROM photo WHERE aid
IN (SELECT aid FROM album WHERE owner=20531316728)ORDER BY share_count desc
I do want to order the last 20 pictures with there share count. Can somebody help me how could I achieve this.
I am not writing an application. Just testing it in Graph API explorer v2.0 API in developer tools.
This isn't possible because there exists no share_count field in the FQL photo table. https://developers.facebook.com/docs/reference/fql/photo/

Get all photos the user is tagged in on 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.

FQL: Retrieving photos that have multiple friends tagged

How would I retrieve all the photos that have multiple friends tagged given a few friend IDs?
The following doesn't seem to retrieve all photos (or any in many cases):
SELECT object_id, src_big FROM photo WHERE pid IN
(SELECT pid FROM photo_tag WHERE subject = me() AND pid IN
(SELECT pid FROM photo_tag WHERE subject=<friend ID1>)) AND pid IN
(SELECT pid FROM photo_tag WHERE subject=<friend ID2>))
Would I need to specifically query within friend 1 and friend 2's photo albums?
I agree Facebook API may not even return all the photos I was tagged in. But i believe it may be because of the privacy setting of the person who tagged me. I have tried similar request using via the Graph API too but no luck. (Exact same results)
I ran you query and it worked fine for me. (Except you have a extra bracket at end). It does return me all the photos I have tagged myself but only some of friend photos in which I was tagged. I do have friends_photo permission ( You may want to check for yours) . I have also tried running following commands but it still didn't return me all the pics which my friends have tagged me.
SELECT object_id, src_big, caption FROM photo WHERE owner!=me() and pid IN
(SELECT pid FROM photo_tag WHERE subject = me())

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.

How to get total number of albums of all facebook friends?

How to get total number of albums of all facebook friends?
I want to retrieve all facebook friends total albums in one go.
Anyone have have idea how to query "album" table in FB
plz share ur thoughts thanks
I've came across this link earlier today, sound similar to your question
FQL for returning all album names and object id's of the albums for ALL friends of a user
If you removed the "LIMIT 25" as ifaour mentioned from his example side note, the query would look like this and do the task
SELECT aid, owner, name FROM album WHERE owner IN (SELECT uid2 FROM friend WHERE uid1=me())
2nd step: let's put it into a multi-query format
{"query1":"SELECT aid, owner, name FROM album WHERE owner IN (SELECT uid2 FROM friend WHERE uid1=me())","query2":"SELECT owner, album_object_id, object_id FROM photo WHERE aid IN (SELECT aid FROM #query1)"}
I guess you'll need to modify the fields in query2 to fit it into your scenario
These will return as 2 big fat json objects with 5000 results limit... which I haven't figured out a solution to query the next 5000 and the rest...
Also, I think there's a bug in both FQL and Graph API, some of my friends' albums are NOT showing in the result... (yes, with the right permission and necessary scopes to browse and query...) I've fired a bug report for this issue