Textlocal Logo

API Documentation

Get Cost

This command can be used to get the cost of a send without sending the message. You need to follow these steps to get the cost of a send

Sample Request

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

	// Message details
	$numbers = array(918123456789,918987654321);
	$sender = urlencode('TXTLCL');
	$message = urlencode('This is your message');

 	$numbers = implode(',', $numbers);

	// Prepare data for POST request
	$data = array('apikey' => $apiKey, 'numbers' => $numbers, "sender" => $sender, "message" => $message, "test" => '1');
 
	// Send the POST request with cURL
	$ch = curl_init('https://api.textlocal.in/send/');
	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
	$responseArray = json_decode($response, true);
	$cost = $responseArray['cost'];
	echo $cost;

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

	// Message details
	$numbers = urlencode('918123456789,918987654321');
	$sender = urlencode('TXTLCL');
	$message = urlencode('This is your message');

	// Prepare data for POST request
	$data = 'apikey=' . $apiKey . '&numbers=' . $numbers . "&sender=" . $sender . "&message=" . $message . "&test=1";

	// Send the GET request with cURL
	$ch = curl_init('https://api.textlocal.in/send/?' . $data);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	$response = curl_exec($ch);
	curl_close($ch);

	// Process your response here
	$responseArray = json_decode($response, true);
	$cost = $responseArray['cost'];
	echo $cost;
?>