使用适用于PHP的Google API客户端库检索成员的所有组

时间:2023-01-21 15:49:14

I am using the Google APIs Client Library for PHP but I do not see a function to Retrieve all groups for a member yet it exists in the Directory API: GET https://www.googleapis.com/admin/directory/v1/groups?userKey=user key

我正在使用适用于PHP的Google API客户端库但我没有看到一个功能来检索成员但是它存在于目录API中的所有组:GET https://www.googleapis.com/admin/directory/v1/groups ?userKey =用户密钥

Is it missing?

它丢失了吗?

Has somebody figured out how to do this using the PHP Library?

有人想弄清楚如何使用PHP库吗?

1 个解决方案

#1


You would use the groups.list() method which is the same method you use to list all groups in the Google Apps account. The only difference is you specify the userKey attribute to scope the results down to groups that a given user is a member of:

您可以使用groups.list()方法,该方法与您用于列出Google Apps帐户中所有群组的方法相同。唯一的区别是您指定userKey属性以将结果范围限定为给定用户所属的组:

$optParams = array(
  'customer' => 'my_customer',
  'userKey' => 'john@example.com'
);
$results = $service->groups->listGroups($optParams);

#1


You would use the groups.list() method which is the same method you use to list all groups in the Google Apps account. The only difference is you specify the userKey attribute to scope the results down to groups that a given user is a member of:

您可以使用groups.list()方法,该方法与您用于列出Google Apps帐户中所有群组的方法相同。唯一的区别是您指定userKey属性以将结果范围限定为给定用户所属的组:

$optParams = array(
  'customer' => 'my_customer',
  'userKey' => 'john@example.com'
);
$results = $service->groups->listGroups($optParams);