Exemple #1
1
 function adicionaUsuario($nome, $login, $senha)
 {
     // Get the API client and construct the service object.
     $sobrenome = '-';
     $arrayNome = explode(" ", $nome);
     if (count($arrayNome) > 1) {
         $sobrenome = $arrayNome[1];
     }
     $client = $this->getClient();
     $service = new Google_Service_Directory($client);
     $postBody = new Google_Service_Directory_User();
     $postBody->setPrimaryEmail($login . '@smt.ufrj.br');
     $objNome = new Google_Service_Directory_UserName();
     $objNome->setFullName($arrayNome[0] . " " . $sobrenome);
     $objNome->setFamilyName($sobrenome);
     $objNome->setGivenName($arrayNome[0]);
     $postBody->setName($objNome);
     $postBody->setPassword(md5($senha));
     $postBody->setSuspended(false);
     $postBody->setHashFunction("MD5");
     $postBody->setChangePasswordAtNextLogin(true);
     //$
     $insert = $service->users->insert($postBody);
 }