使用群组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
答案 0 :(得分: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);