Textlocal Logo

API Documentation

Get Group Message History

This command will retrieve history of group messages sent.

Resource URL

https://api.txtlocal.com/get_history_group/

Sample Request

<?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.txtlocal.com/get_history_group/');
	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;
 
	// Send the GET request with cURL
	$ch = curl_init('https://api.txtlocal.com/get_history_group/?' . $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 = time(); // Get sends between now 
	$max_time = strtotime('-1 month'); // and a month ago 
	$limit = 1000;
	$start = 0;
	
	$response = $Textlocal->getGroupMessageHistory($start, $limit, $min_time, $max_time);
	print_r($response);
?>

Parameters

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.

Sample Response

Note: This response will not return a delivery status, but will return a batch ID which can then be passed through to status_batch.

{
	"start":0,
	"limit":1000,
	"total":2,
	"messages":[{
		"batch_id":"134294690",
		"group_id":"189405",
		"group_name":"Customers",
		"message":"This is your message",
		"datetime":"2013-07-04 10:11:12",
		"num_credits":12800
	},
	{
		"batch_id":"131406051",
		"group_id":"189405",
		"group_name":"Staff",
		"message":"This is your other message",
		"datetime":"2013-07-03 10:03:30",
		"num_credits":24
	}],
	"status":"success"
}
<?xml version="1.0" encoding="UTF-8" ?>
<response>
	<start>0</start>
	<limit>1000</limit>
	<total>2</total>
	<messages>
		<message>
			<batch_id>134294690</batch_id>
			<group_id>189405</group_id>
			<group_name>Customers</group_name>
			<message>This is your message</message>
			<datetime>2013-07-04 10:11:12</datetime>
			<num_credits>12800</num_credits>
		</message>
		<message>
			<batch_id>131406051</batch_id>
			<group_id>189405</group_id>
			<group_name>Staff</group_name>
			<message>This is your other messageĀ€</message>
			<datetime>2013-07-03 10:03:30</datetime>
			<num_credits>24</num_credits>
		</message>
	</messages>
	<status>success</status>
</response>

Errors

Error Codes
45 Invalid sort field.
46 Invalid limit value.
47 Invalid sort direction.
48 Invalid timestamp.
63 Invalid start specified.