如何使用他们的API在Facebook上获得共同的朋友名单? [英] How do I get the list of mutual friends on Facebook using their API?

查看:76
本文介绍了如何使用他们的API在Facebook上获得共同的朋友名单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获得自己和另一个用户的共同朋友的列表,但是在文档中找不到任何API。或者我得到一些奇怪的权限错误,我只能得到我的朋友列表,没有其他用户或我得到以下错误:

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 

有没有一个标准的方法来获取共同的朋友的总数或至少我朋友的朋友ids列表?

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?

推荐答案

Ok ...这个给了我一个真正的困难时刻。我设法使用Facebook JS SDK做到这一点。以下是代码段,以防其他人想要这样做:

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;
            });

          }
        );

这篇关于如何使用他们的API在Facebook上获得共同的朋友名单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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