如何在Google +中获取我圈子中的朋友列表

时间:2014-09-09 12:42:40

标签: php api google-plus

我想获取圈子中的朋友列表(Google+)。我没有得到那个名单;我的代码如下:

    require_once('assets/google/Google_Client.php');
    require_once('assets/google/contrib/Google_Oauth2Service.php');
    require_once('assets/google/contrib/Google_PlusService.php');
    $gClient = new Google_Client();
    $gClient->setApplicationName('Login to Google');
    $gClient->setClientId(GOOGLE_CLIENT_ID);
    $gClient->setClientSecret(GOOGLE_CLIENT_SECRET);
    $gClient->setRedirectUri($google_redirect_url);
    $gClient->setDeveloperKey(GOOGLE_DEVELOPER_KEY);
    $gClient->setScopes($scope);
    $google_oauthV2 = new Google_Oauth2Service($gClient);
    $google_plus = new Google_PlusService($gClient);
    if (isset($_GET['code'])){ 
        $gClient->authenticate($_GET['code']);
        $_SESSION['token'] = $gClient->getAccessToken();
        header('Location: ' .filter_var($google_redirect_url,FILTER_SANITIZE_URL));
        return;
    }
    $user = $google_oauthV2->userinfo->get();

我通过调用上述函数来获取我的详细信息

$peoples = $google_plus->people->listPeople('me','visible');

当我使用上述呼叫获取人员列表时,我获得的权限不足(403)。任何人都可以帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:0)