This command will retrieve messages from the specified inbox.
https://api.textlocal.in/get_messages/
<?php
// Account details
$apiKey = urlencode('Your apiKey');
// Inbox details
$inbox_id = '123456';
// Prepare data for POST request
$data = array('apikey' => $apiKey, 'inbox_id' => $inbox_id);
// Send the POST request with cURL
$ch = curl_init('https://api.textlocal.in/get_messages/');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
// Process your response here
echo $response;
?><?php
// Account details
$apiKey = urlencode('Your apiKey');
// Inbox details
$inbox_id = '123456';
// Prepare data for POST request
$data = 'apikey=' . $apiKey . '&inbox_id=' . $inbox_id;
// Send the GET request with cURL
$ch = curl_init('https://api.textlocal.in/get_messages/?' . $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
// Process your response here
echo $response;
?><?php
require('Textlocal.class.php');
$Textlocal = new Textlocal(false, false, 'your apiKey');
$inbox_id = '1234';
$response = $Textlocal->getMessages($inbox_id);
print_r($response);
?>| inbox_id | ID of the inbox found in get_inboxes. |
|---|---|
| Login Parameters (Additional Information) | |
| apiKey | You can create these in your Messenger Control Panel (click here) for each application, and limit the usage of them by host IP Address. |
| Optional Parameters | |
| min_time | Unix timestamp format of the oldest message. If not provided defaults to 6 months ago as of today. |
| max_time | Unix timestamp format of the newest message. If not provided defaults to current time. |
| sort_order | Order in which to sort the response. Either asc or desc. If not provided defaults to asc. |
| sort_field | The field to sort the data by. Can be set to either date or number. If not provided defaults to date. |
| start | Used in conjunction with limit to return a set of messages starting at the position given (such as 24), up to and including the limit. |
| limit | Limit result set returned to a specific number of records. If not provided defaults to 1000. |
{
"inbox_id":123456,
"num_messages":2,
"min_time":1357209840,
"max_time":1372844640,
"sort_order":"asc",
"sort_field":"date",
"start":0,
"limit":1000,
"messages":[{
"number":918123456789,
"message":"Hi, could you please give me a call back?",
"date":"2013-07-03 12:32:41",
"isNew":true,
"status":"D"
},
{
"number":918987654321,
"message":"Thanks for your message",
"date":"2013-07-02 14:53:18",
"isNew":false,
"status":"D"
}],
"status":"success"
}<?xml version="1.0" encoding="UTF-8" ?> <response> <inbox_id>123456</inbox_id> <num_messages>2</num_messages> <min_time>1357210755</min_time> <max_time>1372845555</max_time> <sort_order>asc</sort_order> <sort_field>date</sort_field> <start>0</start> <limit>1000</limit> <messages> <message> <number>918123456789</number> <message>Hi, could you please give me a call back?</message> <date>2013-07-03 12:32:41</date> <isNew>1</isNew> </message> <message> <number>918987654321</number> <message>Thanks for your message</message> <date>2013-07-02 14:53:18</date> <isNew>false</isNew> <status>D</status> </message> </messages> <status>success</status> </response>
| Error Codes | |
| 45 | Invalid sort field. |
|---|---|
| 46 | Invalid limit value. |
| 47 | Invalid sort direction. |
| 48 | Invalid timestamp. |
| 53 | Invalid inbox ID. |
| 54 | No inbox ID specified. |
| 63 | Invalid start specified. |