从Facebook API组中获取所有电子邮件

时间:2016-02-16 07:20:28

标签: facebook

显示随群组附加的所有群组电子邮件

我有以下代码请建议

// get list of groups managed by user
    try {
        $requestGroups = $fb->get('/me/groups');
        $groups = $requestGroups->getGraphEdge()->asArray();
    } catch(Facebook\Exceptions\FacebookResponseException $e) {
        // When Graph returns an error
        echo 'Graph returned an error: ' . $e->getMessage();
        exit;
    } catch(Facebook\Exceptions\FacebookSDKException $e) {
        // When validation fails or other local issues
        echo 'Facebook SDK returned an error: ' . $e->getMessage();
        exit;
    }

    echo "<pre>";
    print_r($groups);
    echo "</pre>";

如下所示获得回复,您可以看到我需要添加群组的电子邮件

Array
(
    [0] => Array
        (
            [name] => Java Developer
            [privacy] => OPEN
            [id] => xxxxxx
        )

    [1] => Array
        (
            [name] => PHP Develop
            [privacy] => OPEN
            [id] => xxxxxx
        )

)

1 个答案:

答案 0 :(得分:1)

群组没有电子邮件。使用Graph API获取任何电子邮件的唯一方法是授权具有email权限的用户并使用以下端点:/me?fields=email