Inbound SMS to UK landline numbers API

HTTP GET/POST variables

If you choose to have the messages delivered by HTTP, you may either use our standard parameters, or create a custom format for compatibility with any existing application.

If you do not specify any custom parameters, we will deliver the message using the default names.

Default name Custom parameters Data
originator %o The sender’s number
destination %d The destination number
message %m The message body
time %t Message timestamp in YYYY-MM-DD HH:MM:SS format
unix_time %x Message timestamp as a Unix timestamp
udh %u The UDH header, e.g.: for decoding concatenated messages
id %i A unique identifier for the message

Once you have successfully purchased your geographical number you will need to follow these steps:

  • Select Text-In -> Inbound Geographic SMS -> Configure Numbers
  • Select Edit on the chosen number
  • Specify “HTTP POST” as the action
  • Enter destination of the script that will handle your POST. E.g. http://www.example.com/script.php

Relay IP address

MO messages to these numbers are relayed from this IP: 194.145.190.4

Example code

Here are some examples of code that can be used with HTTP GET/POST:

PHP

//include the database handling class include("mysqlclass.php");

//Assign POSTED variables

$originator = $_POST['originator'];
$destination = $_POST['destination'];
$message = $_POST['message'];
$time = $_POST['time'];
$unixTime = $_POST['unix_time'];
$udh = $_POST['udh'];
$id = $_POST['id'];

//Create a new instance of the mysql class and write data to database

$mysql = New mysql(0);

$sql = "
INSERT INTO
inbound
(varOriginator, varDestination, varMessage, dtTime, varUnixTime, varUDH, intId)
VALUES ('$originator','$destination', '$message', '$time', '$unixTime', '$udh', '$id')";

$mysql->query($sql);

ASP

org = Request.QueryString("originator");
dest = Request.QueryString("destination");
msg = Request.QueryString("message");
time = Request.QueryString("time");
unix = Request.QueryString("unix_time");
udh = Request.QueryString("udh");
id = Request.QueryString("id");

Response.Write("Originator: " & org & "<br />");
Response.Write("Destination: " & dest & "<br />");
Response.Write("Message: " & msg & "<br />");
Response.Write("Time: " & time & "<br />");
Response.Write("Unix Time: " & unix & "<br />");
Response.Write("UDH: " & udh & "<br />");
Response.Write("ID: " & id & "<br />");
%>

Create MySQL database to store the data

//include the database handling class include("mysqlclass.php");

//Assign POSTED variables

$originator = $_POST['originator'];
$destination = $_POST['destination'];
$message = $_POST['message'];
$time = $_POST['time'];
$unixTime = $_POST['unix_time'];
$udh = $_POST['udh'];
$id = $_POST['id'];

//Create a new instance of the mysql class and write data to database

$mysql = New mysql(0);

$sql = "
INSERT INTO
inbound
(varOriginator, varDestination, varMessage, dtTime, varUnixTime, varUDH, intId)
VALUES ('$originator','$destination', '$message', '$time', '$unixTime', '$udh', '$id')";

$mysql->query($sql);

MySQL class – manages the connection and actions on the database

//include the database handling class include("mysqlclass.php");

//Assign POSTED variables

$originator = $_POST['originator'];
$destination = $_POST['destination'];
$message = $_POST['message'];
$time = $_POST['time'];
$unixTime = $_POST['unix_time'];
$udh = $_POST['udh'];
$id = $_POST['id'];

: connection parameters */
var $debug;
var $hostname;
var $databaseName;
var $username;
var $password;
/* private: connection parameters */
var $conn;
var $rstemp;
var $record;
/**
* mysql::mysql()
* Constructor this class - define public connection parameters and
* call the connect method
*
* @param $hostname
* @param $username
* @param $password
* @param $databaseName
*/
function mysql ($debug=0) {
$this->debug = $debug;
if ($this->debug) echo "\n\nDebug On 
\n"; $this->hostname = 'localhost'; $this->username = 'root'; aql.com Powering a connected society 01133 20 30 40 $this->password = ''; $this->databaseName = 'crmProject'; /** /** * open connection */ $this->connect(); } /** * mysql::connect() * Open connection with the server * * @return id da conexao */ function connect () { /** * Open connection */ if ($this->debug) echo "Connecting to $this->hostname
\n"; $this->conn = @mysql_connect($this->hostname,$this->username,$this->password) or die("Connection to $server failed
\n"); /** * Select to database */ if ($this->debug) echo "Selecting to $this->databaseName
\n"; @mysql_select_db($this->databaseName,$this->conn) or die("Error:" . mysql_errno() . " : " . mysql_error() . "
\n"); return $this->conn; } /** * mysql::query() * Execute SQL * * @param $sql * @return */ function query($sql) { if ($this->debug) echo "Run SQL: $sql
\n\n"; $this->rstemp = @mysql_query($sql,$this->conn) or die("Error:" . mysql_errno() . " : " . mysql_error() . "
\n"); return $this->rstemp; } /** * mysql::num_rows() * return number of records in current select * * @param $rstemp * @return */ function num_rows() { $num = @mysql_num_rows($this->rstemp); if ($this->debug) echo "$num records returneds
\n\n"; return $num; } /** * mysql::movenext() * fetch next record in result * * @return */ function movenext(){ if ($this->debug) echo "Fetching next record ... "; $this->record = @mysql_fetch_array($this->rstemp); aql.com Powering a connected society 01133 20 30 40 $status = is_array($this->record); if ($this->debug && $status) echo "OK
\n\n"; elseif ($this->debug) echo "EOF
\n\n"; return($status); } /** * mysql::getfield() * get field value from the current record * * @param $field * @return */ function getfield($field){ if ($this->debug) { echo "Getting $field ... "; //this resource require PHP 4.1 or righter if (phpversion() >= 4.1) { if (array_key_exists($field,$this->record)) echo "OK
\n\n"; else echo "Not found
\n\n"; } else echo "
\n\n"; } return($this->record[$field]); } }

Inbound action – script which is actioned

<?php
include("mysqlclass.php");

$originator = $_POST['originator'];
$destination = $_POST['destination'];
$message = $_POST['message'];
$time = $_POST['time'];
$unixTime = $_POST['unix_time']; $udh = $_POST['udh'];
$id = $_POST['id'];

$mysql = New mysql(0);
$sql="INSERT INTO inbound (varOriginator, varDestination, varMessage, dtTime, varUnixTime, varUDH, intId) VALUES ('$originator', '$destination', '$message', '$time', '$unixTime', '$udh', '$id') ";
$mysql->query($sql);
?>

Inbound view – view inbound SMS

<?php

include("mysqlclass.php");

$mysql = New mysql(0);
$sql="SELECT * FROM inbound";
$mysql->query($sql);

if ($mysql->num_rows() > 0){
echo "<table cellpadding='1' cellspacing='1' border='0' <tr bgcolor='#cccccc'>";
echo "<tr bgcolor='#e4e4e4'><td><a>intEntryID</a>
      </td><td><a>Originator</a>
      </td><td><a>Destination</a>
      </td><td><a>Message</a>
      </td><td><a>Time</a>
      </td><td><a>Unix Time</a>
      </td><td><a>UDH</a>
      </td><td><a>Id</a>
      </td><td></tr>";

//Fetch each of the query rows in $result array
while ($mysql->movenext()) {

//Print one row of results
echo "\n<tr bgcolor='#e4e4e4'>" .
     "\n\t<td>" . $mysql->getfield("intEntryID") . "</td>" .
     "\n\t<td>" . $mysql->getfield("varOriginator") . "</td>" .
     "\n\t<td>" . $mysql->getfield("varDestination") . "</td>" .
     "\n\t<td>" . $mysql->getfield("varMessage") . "</td>" .
     "\n\t<td>" . $mysql->getfield("dtTime") . "</td>" .
     "\n\t<td>" . $mysql->getfield("varUnixTime") . "</td>" .
     "\n\t<td>" . $mysql->getfield("varUDH") . "</td>" .
     "\n\t<td>" . $mysql->getfield("intId") . "</td>";
     "</tr>";
    } 
//end while loop body

  //Finish the <table>
  echo "\n</table>";
 } // end if $rowsFound body
?>