首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >让mutual_friends在Facebook上参加一个活动

让mutual_friends在Facebook上参加一个活动
EN

Stack Overflow用户
提问于 2014-10-16 07:23:16
回答 1查看 652关注 0票数 1

我有一个event id,我想让所有的mutual_friends参加一个活动。目前,我刚刚从图形API中得到并参加了一些人。如下所示

代码语言:javascript
复制
https://graph.facebook.com/v2.1/event-id/?fields=attending

但我如何过滤共同的朋友呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-10-28 07:57:20

是啊,现在我终于有了自己的答案。作为@We0评论,我尝试找到自己的共同朋友,并尝试使用event_id获取事件出席列表。并与array_search函数合并。下面是我的代码..。

代码语言:javascript
复制
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;
}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26398463

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档