2017-01-10 53 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