The following sample code shows how to retrieve the details of a conversation (ticket)
<?php $LAURL ="https://URL_TO_LiveAgent"; $APIKEY = "ae07484cf29d087d70554b1d5f347ac7"; $conversationID = 'b0dfff7c'; // service URL based on: // https://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: // https://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: https://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'