LiveZilla Live Chat
EN  DE Please sign in or register Hi
What an awesome system! Just implemented it, and looking forward to getting on top of customer support....
Wayne Thompson
Show all reviews


LiveZilla API V2




Examples

Using the LiveZilla API V2 is very simple. We provide examples for PHP but you can use other languages as well.



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 ... 
}  
?>




PHP code to list all yesterday's chat transcripts

<?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_chats_list"]=1;
$postd["p_json_pretty"]=1;

// filter parameters to include yesterday's tickets (100 maximum)
$yesterdayBegin = strtotime("yesterday");
$yesterdayEnd = strtotime("today");

$postd["p_start_after"]=$yesterdayBegin;
$postd["p_start_before"]=$yesterdayEnd;
$postd["p_limit"]=100;
$postd["p_output"]="Plaintext";

$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 chats found");

foreach($response->Chats as $obj)
{
	echo "New chat: " . $obj->Chat->ChatId;
	echo "<br>";
	// further processing ...
}
?>




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>";
	}
}
?>




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 $Fullname = 'John Doe';
	public $Email = 'john@doe.com';
	public $Language = 'EN';
	public $Webspace = '100';
	public $Password = "";
	public $Groups = array("Support","Sales");
	public $PermissionSet = '2121202101000210111101111111111111011111011011022101';
}

$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);
?>




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);
?>




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);
?>




PHP code to add a message to an existing 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_ticketmessage_create"]=1;
$postd["p_json_pretty"]=1;

class TicketMessage
{
	public $Fullname = "Johanna Doe";
	public $TicketId = 11704;
	public $Email = "johanna@jdscompany.com";
	public $Phone = "004988373728";
	public $Type = 0;
	public $Text = "Hello, please help me.";
	public $Subject = "http://www.mywebsite.domain/products";
	public $IP = "217.2.5.1";
	public $Company = "Jdscompany Ltd.";
	//public $Customs = array(array("CustomerNumber","11112726"));
	//public $Comments = array(array("john_doe","comment #1"),array("john_doe","comment #2"));
}

$newMessage = new TicketMessage();
$postd["p_data"]= json_encode(array("TicketMessage"=>$newMessage));
$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);
?>




PHP code to assign an operator to 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_ticketeditor_assign"]=1;
$postd["p_json_pretty"]=1;

class TicketEditor
{
	public $Id = "11967";
	public $Editor = "john_doe";
}

$neweditor = new TicketEditor();
$postd["p_data"]= json_encode(array("TicketEditor"=>$neweditor));
$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);
?>




PHP code to list Knowledge Base Entries

<?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_knowledgebase_entries_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->KnowledgeBaseEntries) == 0) 
	exit("No KnowledgeBase entries found");

foreach($response->KnowledgeBaseEntries as $obj) 
{ 
	echo "Entry: " . $obj->KnowledgeBaseEntry->Title; 
	echo "<br>"; 
	// further processing ... 
}  
?>




PHP code to create a Knowledge Base Entry

<?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_knowledgebase_entry_create"]=1;
$postd["p_json_pretty"]=1;

class KnowledgeBaseEntry
{
    public $Tags = "car, sharing";
    public $Value = "Content goes here ....";
    public $Title = "Where to find car sharing stations?";
    public $ParentId = "ae33b353c9174c3f97628067f8104405";
    public $Type= 1;
    public $IsPublic = 1;
    public $FulltextSearch = 1;
    public $ShortcutWord = "myshortcut";
    public $AllowBotAccess = 1;
}

$newKBEntry = new KnowledgeBaseEntry();
$postd["p_data"]= json_encode(array("KnowledgeBaseEntry"=>$newKBEntry));
$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);
?>






PHP code to execute CronJobs

<?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_cronjob_execute"]=1;
$postd["p_send_chat_transcripts"]=1;
$postd["p_receive_emails"]=1;
$postd["p_maintenance"]=1;
$postd["p_social_media"]=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);

?>




Something missing?


If you find anything missing please let us know and we will add the missing structures right away. Thanks.