Home > Technical Support > LiveAgent API > REST API > Examples > Retrieve the details of a conversation (ticket)

Retrieve the details of a conversation (ticket)

The following sample code shows how to retrieve the details of a conversation (ticket)
 
<?php
$LAURL ="http://URL_TO_LiveAgent";
$APIKEY = "ae07484cf29d087d70554b1d5f347ac7";
$conversationID = 'b0dfff7c';

// service URL based on:
// http://support.qualityunit.com/840770-Complete-API-reference#87abf7ff1b8dd576caf5194e502354cf
$service_url = $LAURL.'/api/conversations/'.$conversationID.'?apikey='.$APIKEY;
$curl = curl_init($service_url);

// curl POST request based on:
// http://support.qualityunit.com/061754-How-to-make-REST-calls-in-PHP
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$curl_response = curl_exec($curl);
if ($curl_response === false) {
	$info = curl_getinfo($curl);
	curl_close($curl);
	die('error occured during curl exec. Additioanl info: ' . var_export($info));
}
curl_close($curl);

$decoded = json_decode($curl_response);
if (isset($decoded->response->status) && $decoded->response->status == 'ERROR') {
	die('error occured: ' . $decoded->response->errormessage);
}

// see the response	
var_export($decoded->response);
?>
 
Sample output of 'var_export($decoded->response)':
//Sample output:
http://localhost/la/api/conversations/f82fe82e?apikey=ae07484cf29d087d70554b1d5f347ac7
stdClass::__set_state(array( 'conversationid' => 'b0dfff7c', 'code' => 'NHQ-XMCAP-686', 
'datecreated' => '2014-04-16 09:25:45', 'datechanged' => '2014-04-16 09:45:35', 'departmentname' => 'General', 
'departmentid' => 'default', 'status' => 'N', 'ownername' => 'Test Customer', 
'owneremail' => 'customer@mailaddress.com', 'subject' => 'Test conversation', 'ownernote' => '', 
'preview' => 'This is a sample test message.', 'publicurlcode' => 'z4M6AA4BYn1Sh7cf', 'assignedto' => 'owner123', ))
 
You can retrieve any of those output details even separately. 
E.g. if you wanted retrieve only the id of agent to whom the ticket is assigned to then you would use:
'$decoded->response->assignedto'
 
or if you wanted to retrieve the email address of the customer then you would use:
'$decoded->response->owneremail'

Ready to try LiveAgent?

It's free for the first 14 days! No credit card required.

Get Started
We work well with others...
Magento Joomla Wordpress Mailchimp
Contact us

support@ladesk.com

+1-800-811-6590 (Toll Free in USA & Canada)

+421 2 33 456 826 (European Union & Worldwide)

Quality Unit, LLC 616 Corporate Way, Suite 2-3278 Valley Cottage, NY 10989

Stay in touch
Blog Google+
© 2004-2015 QualityUnit.com, All rights reserved