Issue
I have an event id
and I want to get all mutual_friends attending an Events. Currently I just got and attending people from graph API. Like the following
https://graph.facebook.com/v2.1/event-id/?fields=attending
But how I can filter mutual friends?
Solution
Yeah, now I finally got my own answer. As @We0 comment I try to get my own mutual friends and I try to got event attend list using event_id
. And I merge with array_search
function. And the following is my code...
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;
}
Answered By - Set Kyar Wa Lar
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.