public function create_user_account($user_info) { $password = $this->createPassword(); $client = new Google_Client(); $client->setAssertionCredentials($this->credential); $service = new Google_Service_Directory($client); $user = new Google_Service_Directory_User(); $name = new Google_Service_Directory_UserName(); $name->setFamilyName($user_info['familyname']); $name->setGivenName($user_info['givenname']); $user->setPassword($password); $user->setPrimaryEmail($user_info['accountname'] . "@" . $this->domain); $user->setName($name); $user->setChangePasswordAtNextLogin(true); $res[0] = $service->users->insert($user); $res[1] = $password; return $res; }
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); }