List Operators
Function
As of version 5.2.5.0
POST /api/v2/api.php p_operators_list=1
|
Filters
Name |
POST Key |
Type |
Required |
Comment |
Example |
UserId | p_userid | string | No | Response will be the Operator matching this login Id. | john_doe | Status | p_status | int | No | Returns all operators having this status. | 1 | Group | p_group | string | No | Returns all operators that are member of this group. | groupid1 | Full Chats | p_full_chats | bool | No | Return full list of external chat objects (LiveZilla 5.4.0.1). | 1 |
|
CURL Example
curl {yourdomain}{livezilla_folder}/api/v2/api.php -d {authenthication} -d p_operators_list=1 -X POST
|
Response
200 Ok: {
"Operators": [
{
"Operator": {
"Level": "1",
"Webspace": 100,
"Password": "a8c054e6b5e3edf349c1dac58157d1cd",
"Description": "Nice guy",
"PermissionSet": "2121202101000210111101111111111111011111011011022101",
"Groups": [
"groupid1",
"groupid2"
],
"UserId": "john_doe",
"Language": "EN",
"Fullname": "John Doe",
"Email": "john@doe.com"
}
},
{
"Operator": {
"Level": "1",
"Webspace": 100,
"Password": "a8c054e6b5e3edf349c1dac58157d1cd",
"Description": "Nice guy",
"PermissionSet": "2121202101000210111101111111111111011111011011022101",
"Groups": [
"groupid1",
"groupid2"
],
"UserId": "john_doe",
"Language": "EN",
"Fullname": "John Doe",
"Email": "john@doe.com"
}
}
]
}
|
Error Codes
403 Forbidden: Invalid or no user authentication data sent (see General API Authentication)
400 Bad Data: Invalid or missing POST parameters (see required fields/filters and data types)
|
Example: PHP code to list all online operators with chat link and image
<?php
$livezillaURL = "http(s)://{yourdomain}/livezilla/";
$apiURL = $livezillaURL . "api/v2/api.php";
// authentication parameters
$postd["p_user"]='{user_id}';
$postd["p_pass"]=md5('{user_password}');
// function parameter
$postd["p_operators_list"]=1;
$postd["p_json_pretty"]=1;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$apiURL);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($postd));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec($ch);
if($server_output === false)
exit(curl_error($ch));
echo $server_output;
echo "<hr>";
curl_close($ch);
$response = json_decode($server_output);
if(count($response)==0)
exit("No operators found");
foreach($response->Operators as $obj)
{
if($obj->Operator->Status < 2 && !$obj->Operator->IsBot)
{
echo "<img src=\"" . $livezillaURL . $obj->Operator->PictureFile . "\"> ";
echo $obj->Operator->Fullname . " is online ";
echo "<a href=\"" . $livezillaURL . $obj->Operator->ChatFile . "\" >Chat</a><br>";
}
}
?>
Create Operator
Function
As of version 5.2.5.0
POST /api/v2/api.php p_operator_create=1
|
Filters
Name |
POST Key |
Type |
Required |
Comment |
Example |
|
CURL Example
curl {yourdomain}{livezilla_folder}/api/v2/api.php -d {authenthication} -d p_operator_create=1 -d p_data={
"Operator": {
"Level": "1",
"Webspace": 100,
"Password": "a8c054e6b5e3edf349c1dac58157d1cd",
"Description": "Nice guy",
"PermissionSet": "2121202101000210111101111111111111011111011011022101",
"Groups": [
"groupid1",
"groupid2"
],
"UserId": "john_doe",
"Language": "EN",
"Fullname": "John Doe",
"Email": "john@doe.com"
}
} -X POST
|
Response
200 Ok: {
"Operator": {
"Level": "1",
"Webspace": 100,
"Password": "a8c054e6b5e3edf349c1dac58157d1cd",
"Description": "Nice guy",
"PermissionSet": "2121202101000210111101111111111111011111011011022101",
"Groups": [
"groupid1",
"groupid2"
],
"UserId": "john_doe",
"Language": "EN",
"Fullname": "John Doe",
"Email": "john@doe.com"
}
}
|
Error Codes
403 Forbidden: Invalid or no user authentication data sent (see General API Authentication)
400 Bad Data: Invalid or missing POST parameters (see required fields/filters and data types)
|
Example: PHP code to create an operator account
<?php
$livezillaURL = "http(s)://{yourdomain}/livezilla/";
$apiURL = $livezillaURL . "api/v2/api.php";
// authentication parameters
$postd["p_user"]='{user_id}';
$postd["p_pass"]=md5('{user_password}');
// function parameter
$postd["p_operator_create"]=1;
$postd["p_json_pretty"]=1;
class Operator
{
public $UserId = 'john_doe';
public $Firstname = 'John';
public $Lastname = 'Doe';
public $Email = 'john@doe.com';
public $Language = 'EN';
public $Webspace = '100';
public $Password = "";
public $Roles = "f7d450ede1fe1d035689c967f0836dfd";
public $Skills = "purchasing";
public $Location = "usa";
public $Groups = array("support","sales");
}
$newOperator = new Operator();
$newOperator->Password = md5("johnspassword");
$postd["p_data"]= json_encode(array("Operator"=>$newOperator));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$apiURL);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($postd));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec($ch);
if($server_output === false)
exit(curl_error($ch));
echo $server_output;
curl_close($ch);
?>
Delete Operator
Function
As of version 5.2.5.0
POST /api/v2/api.php p_operator_delete=1
|
Filters
Name |
POST Key |
Type |
Required |
Comment |
Example |
|
CURL Example
curl {yourdomain}{livezilla_folder}/api/v2/api.php -d {authenthication} -d p_operator_delete=1 -d p_userid=john_doe -d p_data={
"Operator": {
"UserId": "john_doe"
}
} -X POST
|
Response
200 Ok: {
"Operator": {
"Level": "1",
"Webspace": 100,
"Password": "a8c054e6b5e3edf349c1dac58157d1cd",
"Description": "Nice guy",
"PermissionSet": "2121202101000210111101111111111111011111011011022101",
"Groups": [
"groupid1",
"groupid2"
],
"UserId": "john_doe",
"Language": "EN",
"Fullname": "John Doe",
"Email": "john@doe.com"
}
}
|
Error Codes
403 Forbidden: Invalid or no user authentication data sent (see General API Authentication)
400 Bad Data: Invalid or missing POST parameters (see required fields/filters and data types)
|
Example: PHP code to delete an operator account
<?php
$livezillaURL = "http(s)://{yourdomain}/livezilla/";
$apiURL = $livezillaURL . "api/v2/api.php";
// authentication parameters
$postd["p_user"]='{user_id}';
$postd["p_pass"]=md5('{user_password}');
// function parameter
$postd["p_operator_delete"]=1;
$postd["p_json_pretty"]=1;
class Operator
{
public $UserId = 'john_doe';
}
$deleteOperator = new Operator();
$postd["p_data"]= json_encode(array("Operator"=>$deleteOperator));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$apiURL);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($postd));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec($ch);
if($server_output === false)
exit(curl_error($ch));
echo $server_output;
curl_close($ch);
?>