本文介绍了FQL Graph API:互助朋友的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道你不能得到朋友的朋友,但是可以用计算效率的方式,使用一些查询来获得共同的朋友吗?
I know you can't get friends of friends, but can you get mutual friends using some query, in a computationally efficient manner?
我可以迭代我的朋友们看看他们中的哪一个是有目标的朋友?有没有什么好的方法来获得互惠的朋友?
Could I even iterate through my friends to see which of them is friends with a target? Is there any good way to get Mutual friends?
推荐答案
你可以这样做:
$facebook = new Facebook(array(
'appId' => FB_ID,
'secret' => FB_APP_SECRET,
'cookie' => true,
));
$fql = "SELECT id FROM profile WHERE id IN (SELECT uid2 FROM friend WHERE uid1=me())";
$response = $facebook->api(array(
'method' => 'fql.query',
'query' =>$fql,
));
这将返回共同的朋友的ID。希望这可以帮助你:)
This will return the id of the mutual friends. Hope this helps you :)
编辑:
如果你想得到你和id之间的共同的朋友= 13245那么你可以这样做:
If you want to get the mutual friends between you and id=13245 then you can do like:
$facebook = new Facebook(array(
'appId' => FB_ID,
'secret' => FB_APP_SECRET,
'cookie' => true,
));
$fql = "SELECT uid1, uid2 FROM friend WHERE uid1 IN (SELECT uid2 FROM friend WHERE uid1=me() AND uid2 = '13245' ) AND uid2 IN (SELECT uid2 FROM friend WHERE uid1=me())";
$response = $facebook->api(array(
'method' => 'fql.query',
'query' =>$fql,
));
它将返回所有共同的朋友ID。
It will return all mutual friends id.
希望这给你想要的。
这篇关于FQL Graph API:互助朋友的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!