Facebook Graph API互相朋友 [英] Facebook Graph API mutual friends

查看:108
本文介绍了Facebook Graph API互相朋友的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Facebook图形API,我正在检索2个用户拥有的共同朋友的数量。但是,我正在获得其中一个的朋友的数量。

Using Facebook graph API, I am trying to retrieve number of mutual friends 2 users have. However, I am getting number of friends of one of them instead.

这是我的代码:

    <?php

    $mutual_array = json_decode(file_get_contents("https://graph.facebook.com/".$fb_id."/mutualfriends/".$other_fb_id."?".$access_token), true);

    $mutual_friends = $mutual_array['data'];
    $mutual_number = count($mutual_friends);

    ?>

$ mutual_number给出用户拥有的Facebook的朋友的数量$ other_fb_id。而当我尝试print_r $ mutual_friends它给所有的用户的朋友。

$mutual_number gives the number of facebook friends $other_fb_id user has. And when I try to print_r $mutual_friends it gives all the friends the user has.

任何人都知道这里发生了什么?谢谢。

Anyone know what's going on here? Thanks.

推荐答案

这是一个facebook api错误。即使信息是对称的,为了获得共同的朋友数量,您必须使用当前用户(用户a)的访问令牌,而不是您正在检查的其他用户的访问令牌。

This is a facebook api bug. Even though the information is symetrical, to get the number of mutual friends, you have to use the access token of the current user (user a), not of the other user you are checking with.

这篇关于Facebook Graph API互相朋友的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆