2017-01-10 52 views
0

我需要Google上自定义方案的帮助。 我成功从代表团获取用户列表。 以下是我的代码。Google管理员SDK自定义方案问题

$client = new \Google_Client(); 
$client->setApplicationName('xx'); 
$scopes = array('www.googleapis.com/auth/admin.directory.user','www.googleapis.com/auth/admin.directory.userschema'); 
$client->setAuthConfig('C:\Users\xx\xx\public\client_secret.json'); 
$client->setScopes($scopes); 
$user_to_impersonate = 'xx.sg'; 
$client->setSubject($user_to_impersonate); 

$dir = new \Google_Service_Directory($client); 
$r = $dir->users->get('[email protected]'); 
dd($r); 

Userscheme也已添加到Google中。

但我得到的自定义方案是空的。

https://i.stack.imgur.com/0JcfZ.png

如果我使用投影=充满developers.google.com/admin它的工作原理。

https://i.stack.imgur.com/9s3MQ.png

有人能帮忙吗?

回答

0

documentation说:

您可以通过在users.getusers.list请求customfull设置projection参数用户配置文件中提取的自定义字段。

所以我会取代你行:

$r = $dir->users->get('[email protected]'); 

有:

$optParams = array('projection' => 'full'); 
$r = $dir->users->get('[email protected]', $optParams); 
+0

感谢彼得。这是工作。希望你有一个美好的一天。 – Jerry