douzhan1031 2012-06-22 00:17 采纳率: 0%
浏览 60
已采纳

获取Facebook好友列表,同时也排除一些

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.

  • 写回答

2条回答 默认 最新

  • douan6815 2012-06-22 00:54
    关注

    "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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?