问题描述
我正在编写一个 android 应用程序,它将拉入所有用户朋友的列表,以便他们可以在照片中标记他们,但会显示一个带有照片的大框朋友而不是列表.因为有些人有 500 多个朋友,我们都知道他们只有少数(可能 50 个)是他们通过评论或在照片中标记在 Facebook 上积极交流的朋友.我希望能够只拉他们的顶级 xxx 朋友,因为 Facebook 在他们的网站上似乎做了同样的事情,但我在 Graph API 中找不到任何东西来完成这项任务.
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.
有大佬指点一下吗?
推荐答案
另一种方式是,对用户发布的状态消息进行 Graph API 请求,评论或喜欢他状态的朋友是与他/她互动最多的人,这样做很简单,你可以使用这个:
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 - 寻找用户的顶级好友的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!