Textlocal Logo

API Documentation

POST Received SMS to URL Messages

You can configure any of your Textlocal inboxes to send a notification to a URL whenever you receive a message; this is perfect for two-way communication via your website or application. To enable message notifications, simply enter your URL into the relevant inbox settings within Messenger.

Example Handler On Your Webserver

<?php
 $inNumber = $_REQUEST["inNumber"];
 $sender = $_REQUEST["sender"];
 $keyword = $_REQUEST["keyword"];
 $content = $_REQUEST["content"];
 $email = $_REQUEST["email"];
 $credits = $_REQUEST["credits"];
 
 // Example: Writing to a file //
 // File format: sender, content //
 $fp = fopen('data.csv', 'a');
 fwrite($fp, ".$sender.", ".$content."\r\n"");
 fclose($fp);
 
 // Example: Writing to a database //
 $mysqlic = new mysqli("localhost", $database_username, $database_password, $database_name);
 if (mysqli_connect_error()) { die('Connect Error: '.mysqli_connect_errno().' - '.mysqli_connect_error()); };
 $sql = "INSERT INTO inbound_contact (sender, message) ";
 $sql .= "'".mysqli_real_escape_string($sender)."', ";
 $sql .= "'".mysqli_real_escape_string($content)."')";
 $mysqlic->query($sql);
 
?>

Parameters

sender The sender's mobile phone number in international format. For example, UK numbers will be formatted as 447123456789.
keyword If applicable, the keyword of the inbox.
content The full message content.
comments If applicable, the message without the inbox keyword.
inNumber The inbound number the message was sent to.
email Any email address extracted from the message.
credits The number of SMS credits remaining in your Textlocal account.