【问题标题】:Google PHP API create users aliasesGoogle PHP API 创建用户别名
【发布时间】:2015-10-06 04:35:49
【问题描述】:

基于来自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();
[....]

我需要为指定的用户创建多个电子邮件别名。 知道我在哪里可以找到解决方案或规范吗?

【问题讨论】:

    标签: php api


    【解决方案1】:

    这将为现有用户添加一个别名。

       // 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);
    

    【讨论】:

      猜你喜欢
      • 2015-12-18
      • 2019-03-29
      • 1970-01-01
      • 1970-01-01
      • 2012-07-29
      • 1970-01-01
      • 2021-09-30
      • 1970-01-01
      • 2022-01-09
      相关资源
      最近更新 更多