This command will retrieve history of messages sent through the API.
https://api.textlocal.in/get_history_api/
<?php // Account details $apiKey = urlencode('Your apiKey'); // Prepare data for POST request $data = array('apikey' => $apiKey); // Send the POST request with cURL $ch = curl_init('https://api.textlocal.in/get_history_api/'); 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'); // Prepare data for POST request $data = 'apikey=' . $apiKey; // Send the GET request with cURL $ch = curl_init('https://api.textlocal.in/get_history_api/?' . $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'); $min_time = strtotime('-1 month'); // Get sends between a month ago $max_time = time(); // and now $limit = 1000; $start = 0; $response = $Textlocal->getAPIMessageHistory($start, $limit, $min_time, $max_time); print_r($response); ?>
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 desc. |
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. |
{ "start": 0, "limit": 1000, "total": 2, "messages": [{ "id": 18920476, "number": 918123456789, "content": "This is your message", "sender": "Name", "datetime": "2013-07-04 09:36:53", "status": "D" "customID": "'123', "links": [] }, { "id": 18920477, "number": 918987654321, "content": "This is your other message with links https://tx.vc/r/mhP1, https://tx.vc/r/c4Nb", "sender": "Name", "datetime": "2013-07-03 15:02:12", "status": "D", "customID": "'321', "links": [{ "originalUrl": "http://awesomelink.co.uk/", "key": "mnOj", "clickCount": "1" }, { "originalUrl": "http://anotherawesomelink.co.uk/", "key": "mnOk", "clickCount": "654" } ] } ], "status": "success" }
<?xml version="1.0" encoding="UTF-8" ?> <response> <start>0</start> <limit>1000</limit> <total>2</total> <messages> <message> <id>18920476</number> <number>918123456789</number> <content>This is your message</content> <datetime>2013-07-04 09:36:53</datetime> <sender>Company</sender> <status>D</status> <customID>123</customID> <links></links> </message> <message> <id>18920477</number> <number>918987654321</number> <content>This is your other message with links https://tx.vc/r/mhP1, https://tx.vc/r/c4Nb</content> <sender>Company</sender> <datetime>2013-07-03 15:02:12</datetime> <status>D</status> <customID>321</customID> <links> <link> <originalUrl> http://www.google.co.uk </originalUrl> <key> mnOh </key> <clickCount> 3 </clickCount> </link> </links> </message> </messages> <status>success</status> </response>
Error Codes | |
45 | Invalid sort field. |
---|---|
46 | Invalid limit value. |
47 | Invalid sort direction. |
48 | Invalid timestamp. |
63 | Invalid start specified. |