Carson
Carson

Reputation: 4651

Find out which friends have photo tags with FQL query

I'm trying to get a list of friends that are tagged in a photo. I'm not interested in how many, what photo or anything else - just a yes or no.

The following query tries to get every tag associated with a user in my friend's list. I would prefer to limit it to one result for each user since the results are too large any other way.

SELECT text, subject FROM photo_tag WHERE subject IN (SELECT uid2 FROM friend WHERE uid1=58015959)

Any ideas? I'm open to using the Graph API if that works too. Thanks in advance.

Upvotes: 1

Views: 1068

Answers (2)

Carson
Carson

Reputation: 4651

Unfortunately there is no easy and effecient way to get a yes/no answer to this query in FQL.

You can, however, query http://graph.facebook.com/{user-id}/photos. I was over-complicating this step and missed the fact that /photos only returns photos that the user ID is tagged in rather than all of their uploaded images.

Upvotes: 1

cpilko
cpilko

Reputation: 11852

This will give you a list of friends who have been tagged in a photo:

SELECT name FROM user WHERE uid IN 
   (SELECT subject FROM photo_tag WHERE subject IN 
       (SELECT uid2 FROM friend WHERE uid1=me())
    LIMIT {n} 1000 )

If you've got a lot of friends who are active taggers, you'll need to iterate this query over {n}, where {n} = 1000 * number of times you've run the query + 1.

Upvotes: 1

Related Questions