admin管理员组文章数量:1303427
I am trying to get a list of mutual friends of myself and another user but none of the API I found in the documentation works. Either I get some weird permission errors that I can only get my friends list and no other user or I get the following error:
Fatal error: Call to a member function friends_getMutualFriends() on a non-object in /home/app.php on line 27
Is there a standard way that is used to get the total number of mutual friends or at least the list of friend ids of my friend?
I am trying to get a list of mutual friends of myself and another user but none of the API I found in the documentation works. Either I get some weird permission errors that I can only get my friends list and no other user or I get the following error:
Fatal error: Call to a member function friends_getMutualFriends() on a non-object in /home/app.php on line 27
Is there a standard way that is used to get the total number of mutual friends or at least the list of friend ids of my friend?
Share Improve this question asked Oct 25, 2010 at 0:23 LegendLegend 117k123 gold badges284 silver badges406 bronze badges5 Answers
Reset to default 5This will give a list of mutual friends:
$mutual_friends = $facebook->api('/me/mutualfriends/friendid');
Ok... This one gave me a real hard time. I managed to do this using the Facebook JS SDK. Here's the snippet just in case anyone else wants to do this:
FB.api(
{
method: 'fql.query',
query: 'SELECT id FROM profile WHERE id IN (SELECT uid2 FROM friend WHERE uid1=me())'
},
function(response) {
$.each(response, function(json) {
console.info(response[json].id);
FB.api(
{
method: 'friends.getMutualFriends',
target_uid: 'INSERT ANOTHER FRIEND ID HERE'
},
function(response) {
console.info(response);
}
);
return false;
});
}
);
This is working 2016/ JAN
https://graph.facebook./v2.5/[USER_FRIEND_ID]?limit=100&fields=context.fields(mutual_friends.limit(100))&access_token=[YOUR_USER_TOKEN]
The result is a Json with your mon friends. Working in Graph v2.4 and v2.5 fine.
PS: if you searching for ALL_mutual_friend is friends without the same app instaled Mutual_friends -> booth users you from token session and another one in query have the app autorized.
new field in facebook user.context https://developers.facebook./docs/graph-api/reference/user-context/
(Use Graph Explorer to Test )
I had same problem. Though it is very late for answering question, it will help somebody. That's why answering this question.
Legend
given answer is giving only mutual friends for friend. I have given solution which gives mutual friends of user(friend or friend of friend).
You asked mutual friends of myself and another user
(not only friend) and in PHP.
So below is solution:
$source_id=current user
$target_id=friend or friend of friend
$query="SELECT uid, name, work FROM user WHERE uid IN
(SELECT uid2 FROM friend WHERE uid1 = $source_id and uid2 IN (SELECT uid2 FROM friend WHERE uid1 = $target_id) ) ORDER BY name";
$freinds_list=$this->facebook->api(array('method'=>'fql.query',
'query'=>$query));
Well it's actually friends.getMutualFriends().
Have a play here.
本文标签: phpHow do I get the list of mutual friends on Facebook using their APIStack Overflow
版权声明:本文标题:php - How do I get the list of mutual friends on Facebook using their API? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741686902a2392493.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论