我有一个event id,我想让所有的mutual_friends参加一个活动。目前,我刚刚从图形API中得到并参加了一些人。如下所示
https://graph.facebook.com/v2.1/event-id/?fields=attending但我如何过滤共同的朋友呢?
发布于 2014-10-28 07:57:20
是啊,现在我终于有了自己的答案。作为@We0评论,我尝试找到自己的共同朋友,并尝试使用event_id获取事件出席列表。并与array_search函数合并。下面是我的代码..。
function getCommonFriend($event_id)
{
//Setup Facebook Configuration
$facebook = new Facebook(Config::get('facebook'));
//If there is no common friends so there will be 0
$commmon_friends = 0;
//Get Attending Friends
$event_attending = $facebook->api('v2.1/' .$event_id . '?fields=attending');
$event_attending_friends = $event_attending['attending']['data'];
$events_attending_friends_id = array();
foreach ($event_attending_friends as $key => $value) {
$events_attending_friends_id['id']{$key} = $value['id'];
}
//Get Own Mutual Friends
$me = $facebook->api('v2.1/me?fields=context');
$my_mutual_friends = $me['context']['mutual_friends']['data'];
foreach ($my_mutual_friends as $key => $value) {
$my_mutual_friends_id = $value['id'];
$get_commmon_friends = array_search($my_mutual_friends_id, $events_attending_friends_id['id']);
if (!empty($get_commmon_friends)) {
$commmon_friends ++;
}
}
return $commmon_friends;
}https://stackoverflow.com/questions/26398463
复制相似问题