Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create agents in five9
<?php
/**
* Example usage:
* php five9adduser.php <admin username> <admin password> <agent email> <agent firstname> <agent lastname> <agent password>
*/
error_reporting(E_ALL);
$user = $argv[1];
$pass = $argv[2];
$email = $argv[3];
$firstName = $argv[4];
$lastName = $argv[5];
$agentPass = $argv[6];
echo 'Logging in as '.$user. PHP_EOL;
echo 'Creating user '.$email. PHP_EOL;
$wsdl_five9 = "https://api.five9.com/wsadmin/v2/AdminWebService?wsdl&user=$user";
try {
$client_five9 = new SoapClient(
$wsdl_five9, [
'login' => $user,
'password' => $pass,
'trace' => true,
]
);
$result = $client_five9->createUser(
[
'userInfo' => [
'agentGroups' => 'Team-Lorie Arango',
'generalInfo' => [
'active' => true,
'canChangePassword' => true,
'EMail' => $email,
'firstName' => $firstName,
'lastName' => $lastName,
'mustChangePassword' => false,
'password' => $agentPass,
'userName' => $email,
],
'roles' => [
'agent' => true,
],
],
]
);
$variables = get_object_vars($result);
$resp = get_object_vars($variables['return']);
if (isset($resp['generalInfo']->userName)) {
echo "User created: ".$resp['generalInfo']->userName;
} else {
Throw new \Exception('Unexpected result from five9 '.var_dump($resp, true));
}
} catch (Exception $e) {
echo 'ERROR: '.$e->getMessage();
exit(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.