douzhan1031 2012-06-22 00:17
浏览 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条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度