I'm using the PHP SDK to make an FQL call to pull a list of a user's friends. It looks like this:
$all_friends = $facebook->api(array('method' => 'fql.query', 'query' => 'SELECT uid, name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) ORDER BY name ASC'));
This is working great but now I'd also like to exclude a few friends from the list. I've tried what I assumed would be valid but it appears to not be working (it returns with an empty list).
As an example of what I'm trying to do:
$all_friends = $facebook->api(array('method' => 'fql.query', 'query' => 'SELECT uid, name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND uid NOT IN (12345,54218,68151) ORDER BY name ASC'));
Is there something I'm missing? Thanks.
"NOT IN" is not a supported feature of FQL. The Graph API Explorer throws an exception : (#601) Parser error: unexpected 'NOT' at position 92.
You could do a simple select using IN
$all_friends = $facebook->api(array('method' => 'fql.query', 'query' => 'SELECT uid, name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) ORDER BY name ASC'));
and use PHP for filtering out using the ids.As far as I know it's the only way.
I found a related post: link here.
This is possible using the next FQL query:
SELECT uid, name FROM user WHERE uid IN (
SELECT uid2 FROM friend WHERE uid1 = me()
) AND NOT ( uid IN ('13892588847', '10004291510061', '1000753466073'))
ORDER BY name ASC
Try it on the Graph API Explorer.