用FQL怎么样:
来自 Facebook 的示例:
var friends = FB.Data.query(
"(select uid2 from friend where uid1 = {0})",
user_id);
var friendsoffriends = FB.Data.query(
"select uid2 from friend where uid1 in (select uid2 from {0})",
friends;
// Now, register a callback
FB.Data.waitOn([friends, friendsoffriends], function() {
// now display all the results
FB.Array.forEach(friendsoffriends.value, function(row) {
console.log(row.uid);
});
});
然后编辑您希望使用的任何 id 集合。
上述方法仍然有效(作为一个合理的通用示例) - 但是,澄清一下:
您之前会使用users.getInfo 来执行您所要求的操作,因为这允许您传递 UIDS 列表。不幸的是,这已被弃用。然而,这个查询实际上所做的只是包装一个 FQL 查询。
如果您随后应用标准 FQL 'in' 语法,您可以实现:
{
myfriends:'select uid2 from friend where uid1=me()',
friendsoffriends:'select uid2 from friend where uid1 in (select uid2 from #myfriends)'
}
但是 facebook 会主动阻止您执行此操作并出现错误:
"error_code": 604,
"error_msg": "Can't lookup all friends of 123456789. Can only lookup for the logged in user (987654321), or friends of the logged in user with the appropriate permission",
您的另一个选择是获取所有 id 并执行以下形式的 FQL 查询:
select name from user where uid='123456789' OR uid='987654321' OR uid=...