Facebook Graph API - 查找用户热门的朋友 [英] Facebook Graph API - Finding a users top friends

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

问题描述

我正在写一个Android应用程序,它将拉入所有用户的列表,以便他们可以在照片中标记它们,但是显示一大堆朋友的照片而不是列表。因为有些人有500多个朋友,所以我们都知道他们只是少数(也许50)是朋友,他们通过评论或者照片被标记在Facebook上积极的交流。我希望能够拉他们的顶级的xxx朋友,因为它似乎Facebook在他们的网站上做同样的事情,但是我没有在Graph API中找到任何东西来执行此任务。



任何人都有任何指针?

解决方案

另一种做法是,为用户发布的状态消息,已评论或喜欢他的状态的朋友是与他/她进行交互最多的朋友,这样做很简单,您可以使用以下内容:

  $ statuses = $ facebook-> api('/ me / statuses'); 

foreach($ statuses ['data'] as $ status){
//处理喜欢阵列来计算粉丝群。

foreach($ status ['likes'] ['data'] as $ likesData){
$ frid = $ likesData ['id'];
$ frname = $ likesData ['name'];
$ friendArray [$ frid] = $ frname;
}

foreach($ status ['comments'] ['data'] as $ comArray){
//处理用于计算fanbase的注释数组
$ frid = $ comArray ['from'] ['id'];
$ frname = $ comArray ['from'] ['name'];
}
}

根据您的选择保留柜台,这将是完成。


I am writing a android app that will pull in a list of all the users friends so they can tag them in the photo but displaying a large box of the friends with their photo instead of a list. Because some people have 500+ friends, we all know their are only a handful (maybe 50) that are friends they actively communicate on Facebook by comments or being tagged in photos. I would like to be able to just pull their top xxx friends as it seems Facebook does this same thing on their site, but I just cant find anything in the Graph API to do this task.

Anyone have any pointers?

解决方案

The other way of doing it is, make a Graph API request for the status messages posted by the user, the friends who have commented or liked his status are the ones with whom he/she interacts the most, doing this is pretty simple, you can use this:

    $statuses = $facebook->api('/me/statuses');

    foreach($statuses['data'] as $status){
    // processing likes array for calculating fanbase. 

            foreach($status['likes']['data'] as $likesData){
                $frid = $likesData['id']; 
                $frname = $likesData['name']; 
                $friendArray[$frid] = $frname;
            }

         foreach($status['comments']['data'] as $comArray){
         // processing comments array for calculating fanbase
                    $frid = $comArray['from']['id'];
                    $frname = $comArray['from']['name'];
    }
}

keep counters as per your choice, and it will be done.

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

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