【问题标题】:Google Groups PHP API Get existing GroupGoogle Groups PHP API 获取现有组
【发布时间】:2015-03-16 18:20:49
【问题描述】:

使用 Groups PHP API 并尝试获取现有的组设置和成员。

感谢divideandconquer.se的帮助,我修改了我的代码:

function get_google_group($groupId) {
    $group = false;
    try {
        echo '<br />Getting Google Group: ' . $groupId . '<br />';
        $myClient = $this->getClient();
        $myClient->addScope( 'https://www.googleapis.com/auth/apps.groups.settings');
        $groupsettingsService = new Google_Service_Groupssettings($myClient);
        $group = $groupsettingsService->groups->get($groupId);

        echo 'SUCCESS: group=';

    } catch (exception $e) {
        echo '<br />*** EXCEPTION *** ' . $e->getMessage() . '<br />';
        return false;
    }

    return $group;
}

我仍然遇到异常:在调用“get”方法时:

Getting Google Group: 04k668n33tdjvkw

*** EXCEPTION *** Error calling GET https://www.googleapis.com/groups/v1/groups/04k668n33tdjvkw: (403) GData insufficientPermissions Insufficient Permission 

【问题讨论】:

    标签: google-api-php-client google-groups-api


    【解决方案1】:

    不要直接使用Google_Service_Groupssettings_Groups_Resource。使用Google_Service_Groupssettings,像这样:

     $myClient->addScope('https://www.googleapis.com/auth/apps.groups.settings');
     $groupsettingsService = new Google_Service_Groupssettings($myClient);
     $group = $groupsettingsService->groups->get($groupId);
    

    【讨论】:

    • 谢谢!这当然有帮助。现在我在调用 GET 时遇到错误:insufficientPermissions,但我想我暂时可以使用它。
    • 更新了我的回复,最终修复了权限不足的问题。
    • 必须在 Google_Service_Groupssettings($myClient) 前面添加一个“新”,但代码仍然因权限问题而失败。感谢您迄今为止的帮助。
    • 有趣的是,我可以使用我拥有的权限创建一个新组并添加/删除成员,但无法读取(获取)现有组。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-11
    • 1970-01-01
    • 2016-05-26
    相关资源
    最近更新 更多