Textlocal Logo

API Documentation

Get Survey Results

This command will get the result data for a given survey.

Resource URL

https://api.txtlocal.com/get_survey_results/

Sample Request

<?php
	// Account details
	$apiKey = urlencode('Your apiKey');

	// Survey details
	$survey_id = 123456;

	// Prepare data for POST request
	$data = array('apikey' => $apiKey, 'survey_id' => $survey_id);
 
	// Send the POST request with cURL
	$ch = curl_init('https://api.txtlocal.com/get_survey_results/');
	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');
	
	// Survey details
	$survey_id = '123456';

	// Prepare data for POST request
	$data = 'apikey=' . $apiKey . '&survey_id=' . $survey_id;
 
	// Send the GET request with cURL
	$ch = curl_init('https://api.txtlocal.com/get_survey_results/?' . $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');
	
	$survey_id = 18;
	$start_date = '2013-08-03 00:00:00';
	$end_date = '2013-08-04 00:00:00';
	
	$response = $Textlocal->getSurveyResults($survey_id, $start_date, $end_date);
	print_r($response);
?>

Parameters

survey_id The ID of the survey found in get_surveys.
start_date Unix timestamp format of the date you would like to retrieve results from.
end_date Unix timestamp format of the date you would like to retrieve results to.
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.

Sample Response

{
	"survey_results":{
		"7384":{"group":"Members","number":"447123456789","firstname":"John","lastname":"Doe","custom1":null,"custom2":null,"custom3":null,"datetime":"2013-07-15 11:29:50","complete":"y","device":""},
		"7385":{"group":"Members","number":"447987654321","firstname":"Sarah","lastname":"Smith","custom1":null,"custom2":null,"custom3":null,"datetime":"2013-07-15 12:02:23","complete":"n","device":""}
	}
	,"status":"success"
}
<?xml version="1.0" encoding="UTF-8" ?>
<response>
	<survey_results>
		<survey_result>
			<group>Members</group>
			<number>447123456789</number>
			<firstname>John</firstname>
			<lastname>Doe</lastname>
			<custom1></custom1>
			<custom2></custom2>
			<custom3></custom3>
			<datetime>2013-03-15 11:29:50</datetime>
			<complete>y</complete>
			<device></device>
		</survey_result>
		<survey_result>
			<group>Members</group>
			<number>447987654321</number>
			<firstname>Sarah</firstname>
			<lastname>Smith</lastname>
			<custom1></custom1>
			<custom2></custom2>
			<custom3></custom3>
			<datetime>2013-03-15 12:02:23</datetime>
			<complete>n</complete>
			<device></device>
		</survey_result>
	</survey_results>
	<status>success</status>
</response>

Errors

Error Codes
49 Invalid survey ID.
58 No survey ID specified.
63 Invalid start specified.