Search code examples
facebookphotofacebook-fqlphoto-tagging

What is the best way to find photos where ALL tags to be searched on are in the photos using FQL?


If I want to use FQL to search for photos where 2 people are in the photos I can do this using the following code -

$fql_query_url = 'https://graph.facebook.com/' . '/fql?q=SELECT+src_big+FROM+photo+WHERE+pid+IN(SELECT+pid+FROM+photo_tag+WHERE+subject+IN('.$tag_list.'))' . '&access_token=' . $params['access_token'];   

Where the $tag_list variable is a comma separated list of user ids.

This returns the photos where either of those users are tagged in the photo.

However what if I want to find photos where BOTH of the people appear (are tagged) in the photos. Is there a good way to do this? What if I want to find a large group of people in the photos. Is it best just to iterate over the results and check that all users are in the photos once the result is returned?

anyone else tackled this? many thanks


Solution

  • fql?q=
    SELECT src_big 
      FROM photo 
     WHERE pid IN (SELECT pid FROM photo_tag WHERE subject ='{uid1}') 
       AND pid IN (SELECT pid FROM photo_tag WHERE subject ='{uid2}')