基于https://developers.google.com/admin-sdk/directory/v1/quickstart/php的示例(使用https://github.com/google/google-api-php-client)
我可以在Google Apps中列出用户别名,例如:
[.....]
$results = $service->users->listUsers($optParams);
if (count($results->getUsers()) == 0) {
print "No users found.\n";
} else {
print "Users:\n";
foreach ($results->getUsers() as $user) {
$email = $user->getPrimaryEmail();
$fullname = $user->getName()->getFullName();
$aliases = $user->getAliases();
[....]
我需要为指定的用户创建多个电子邮件别名。 我知道在哪里找到解决方案或规范如何做到这一点?
答案 0 :(得分:0)
这会为现有用户添加一个别名。
// This is the user account we want to add the alias to
$userKey = 'joesmo@my.test.domain.com';
$alias = 'myalias88@my.test.domain.com';
$dir = new Google_Service_Directory($client);
$aliasObj = new Google_Service_Directory_Alias( array( 'alias' => $alias ) );
$results = $dir->users_aliases->insert($userKey, $aliasObj);
print_r($results->alias);