Description
|
Returns all chat messages between the client and translator to a specific order.
You may provide the message_id parameter if you want to receive a specific message.
|
URL
|
/connect/order/{orderid}/chat
|
Parameters
|
api_key (required)
|
string
|
The public API key of the user. (Details:
Authentication
)
|
timestamp (required)
|
string
|
The current UTC timestamp (seconds from 1/1/1970 until UTC now). (Details:
Authentication
)
|
api_sign (required)
|
string
|
The timestamp encoded with HMAC SHA1 in use of the private key. (Details:
Authentication
)
|
orderid (required)
|
string
|
The unique id of the order (GUID transformed string).
|
message_id
|
string
|
The id of a specific message you want to receive.
|
Example call
$url = 'http://www.nativytest.com/connect/order';
$api_key = 'iQU5lBuEjYFDx2EU2o>bp*202K^Bmie3d}pg-pU^MZ&%mobYM&x7SHY+41u7PHEh';
$private_key = '4i2j_F|=lUqNTxPMxtxsX-veXJ)i+w(hq[_J&(k{Pn[jyT&)xt*Usp3K%B_jv{tP';
$timestamp = gmdate('U');
$hmac = hash_hmac('sha1', $timestamp, $private_key);
$orderid = 'AEA59427-5130-2DFC-8CBB-5E9D88BF6659';
$url = $url
. '/' . $orderid . '/chat'
. '?api_key=' . urlencode($api_key)
. '&api_sign=' . urlencode($hmac)
. '×tamp=' . urlencode($timestamp);
// optional: query a specific message_id:
//. '&message_id=' . urlencode('DC1F4DE4-7137-46B1-B38D-E5ACFDC3331A');
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
$response = curl_exec($ch);
curl_close($ch);
echo ($response);
Return parameters
client_picture_link
|
string
|
A link to nativy which returns the picture of the client 50x50px.
|
message
|
string
|
The chat message to be sent.
|
message_id
|
string
|
The unique ID of the message (GUID).
|
sender
|
string
|
The person who sent the message. Possible values are "translator" or "client".
|
timestamp
|
string
|
Date and time when the message was sent. (seconds from 1/1/1970, already converted
into the client's local timezone)
|
translator_firstname
|
string
|
The first name of the translator that you may show in your chat window.
|
translator_picture_link
|
string
|
A link to nativy which returns the picture of the translator 50x50px.
|
Example return values
[
{
"client_picture_link":"http:\/\/test.nativy.com\/ShowImage.ashx?PersonId=8e2158ad-98cf-4f50-b6d4-6ae85ee7c398&Size=PictureFileSmall",
"message":"What does the word Schneeketten mean?",
"message_id":"a435711b-5244-47db-bfc7-565aff2dabce",
"sender":"translator",
"timestamp":"1338387344",
"translator_firstname":"Yogyakarta",
"translator_picture_link":"http:\/\/test.nativy.com\/ShowImage.ashx?PersonId=b57ead4a-f446-445f-b037-b824bf51672b&Size=PictureFileSmall"
},
{
"client_picture_link":"http:\/\/test.nativy.com\/ShowImage.ashx?PersonId=8e2158ad-98cf-4f50-b6d4-6ae85ee7c398&Size=PictureFileSmall",
"message":"Schneeketten are chains for the car to drive in the snow.",
"message_id":"dfcf9603-40d4-4eb7-9f95-9a9dbc933be9",
"sender":"client",
"timestamp":"1338460650",
"translator_firstname":"Yogyakarta",
"translator_picture_link":"http:\/\/test.nativy.com\/ShowImage.ashx?PersonId=b57ead4a-f446-445f-b037-b824bf51672b&Size=PictureFileSmall"
},
{
"client_picture_link":"http:\/\/test.nativy.com\/ShowImage.ashx?PersonId=8e2158ad-98cf-4f50-b6d4-6ae85ee7c398&Size=PictureFileSmall",
"message":"Thanks!",
"message_id":"dc134de4-7137-46b1-b38d-e5acfdc3331a",
"sender":"translator",
"timestamp":"1338460676",
"translator_firstname":"Yogyakarta",
"translator_picture_link":"http:\/\/test.nativy.com\/ShowImage.ashx?PersonId=b57ead4a-f446-445f-b037-b824bf51672b&Size=PictureFileSmall"
}
]