List Tickets
Function
As of version 5.2.5.0
POST /api/v2/api.php p_tickets_list=1
|
Filters
Name |
POST Key |
Type |
Required |
Comment |
Example |
Id | p_id | string | No | Return the ticket matching this Id. | 11123 | Group | p_group | string | No | Return all tickets of this group. | groupid1 | Operator | p_operator | string | No | Return all tickets of this operator. | john_doe | Created After | p_created_after | string | No | Return all tickets created later than YYYY-MM-DD HH:MM:SS | 2014-01-01 23:59:59 | Created Before | p_created_before | string | No | Return all tickets created earlier than YYYY-MM-DD HH:MM:SS | 2014-01-03 00:00:00 | Limit | p_limit | int | No | Maximum number of tickets to return. | 100 | Status | p_status | string | No | Return all tickets with specific status. Comma-separated list of statuses
[0] = Open [1] = In Progress [2] = Closed [3] = Deleted [4] = Pending | 0,2,3 |
|
CURL Example
curl {yourdomain}{livezilla_folder}/api/v2/api.php -d {authenthication} -d p_tickets_list=1 -d p_limit=10 -X POST
|
Response
200 Ok: {
"Tickets": [
{
"Ticket": {
"Messages": "",
"Group": "groupid1",
"Channel": "0",
"SubChannel": "Sub Channel Name",
"Language": "EN",
"LastUpdated": "1395332206",
"WaitBegin": "1395332157",
"Editor": "",
"Id": "11123"
}
}
]
}
|
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 yesterday's tickets
<?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_tickets_list"]=1;
$postd["p_json_pretty"]=1;
// filter parameters to include yesterday's tickets (100 maximum)
$yesterdayBegin = strtotime("yesterday");
$yesterdayEnd = strtotime("today");
$postd["p_created_after"]=$yesterdayBegin;
$postd["p_created_before"]=$yesterdayEnd;
$postd["p_limit"]=100;
$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->Tickets) == 0)
exit("No tickets found");
foreach($response->Tickets as $obj)
{
echo "New ticket: " . $obj->Ticket->Id;
echo "<br>";
// further processing ...
}
?>
Create Ticket
Function
As of version 5.2.5.0
POST /api/v2/api.php p_ticket_create=1
|
Filters
Name |
POST Key |
Type |
Required |
Comment |
Example |
|
CURL Example
curl {yourdomain}{livezilla_folder}/api/v2/api.php -d {authenthication} -d p_ticket_create=1 -d p_data={
"Ticket": {
"Group": "groupid1",
"Channel": "0",
"SubChannel": "Sub Channel Name",
"Language": "EN"
}
} -X POST
|
Response
200 Ok: {
"Ticket": {
"Messages": "",
"Group": "groupid1",
"Channel": "0",
"SubChannel": "Sub Channel Name",
"Language": "EN",
"LastUpdated": "1395332206",
"WaitBegin": "1395332157",
"Editor": "",
"Id": "11123"
}
}
|
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 a ticket
<?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_ticket_create"]=1;
$postd["p_json_pretty"]=1;
class Ticket
{
public $Group = "support";
public $CreationType = 0;
public $Language = "en";
public $Messages = array();
}
$newTicket = new Ticket();
$postd["p_data"]= json_encode(array("Ticket"=>$newTicket));
$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));
// Please don't miss to add a message to your ticket.
// Tickets with no messages will not be displayed in the operator client software.
echo $server_output;
curl_close($ch);
?>