Skip to content

Instantly share code, notes, and snippets.

@heathdutton
Created May 31, 2019 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heathdutton/a5f29d53b3303e40edf1690cf42bdd0d to your computer and use it in GitHub Desktop.
Save heathdutton/a5f29d53b3303e40edf1690cf42bdd0d to your computer and use it in GitHub Desktop.
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