SMS API developers

API DEVELOPERS

Our API gives you the power to bring the world of texting to your applications. We have been working hard to make sure that interfacing your custom applications with our messaging gateway is easy, reliable and fast.

API Documents:

HTTP POST/GET

HTTP is one of the simplest ways to connect to our API. It's used as an HTTP/Internet Post. We provide a Form Post interface to enable you to integrate SMS functionality into your applications. All services are accessible using either HTTP or HTTPS protocols.

For more information: DOWNLOAD

RESTful WEB SERVICES

RESTful Web Services are a powerful architecture that is well documented, well established, well used technology and methodology. The request and response payload can be sent in the most appropriate format for your platform. All services are accessible using either HTTP or 4096 bit secured HTTPS protocols..

For more information: DOWNLOAD

INBOUND MESSAGING

Our inbound API allows you to receive messages via HTTP POST. You will need to provide us with a URL on your webserver to push the messages to. If this is not possible we are able to send to an email address, so you can periodically poll.

For more information: DOWNLOAD

Programming code examples - SENDING

PHP VIEW SOURCE
$host       = "www.divatxt.co.uk";
$port       = 80;
$method     = "POST";
$path       = "/api/htpost.php";

$myUsername = "myAPIUsername";
$myPassword = "myAPIPassword";
$myMobile   = "myMobileNumber";
$myMessage  = "Testing API using PHP sockets";
$myMessage  = urlencode($myMessage);

$outData    = "username=".$myUsername."&password=".$myPassword."&mobile=".$myMobile."&message=".$myMessage;

// create socket
if (empty($method)) {
	$method = 'GET';
}
$method = strtoupper($method);
$fp = fsockopen($host, $port);
if ($method == 'GET') {
	$path .= '?' . $outData;
}
fputs($fp, "$method $path HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp,"Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: " . strlen($outData) . "\r\n");
fputs($fp, "Connection: close\r\n\r\n");
if ($method == 'POST') {
	fputs($fp, $outData);
}
$buf="";
while (!feof($fp)) {
	$buf .= fgets($fp,1024);
}
fclose($fp);
echo $buf;
ASP.net VIEW SOURCE
host       = "http://www.divatxt.co.uk/api/htpost.php"
myUsername = "myAPIUsername"
myPassword = "myAPIPassword"
myMobile   = "myMobileNumber"
myMessage  = "Test message sent using API"
myMessage  = Server.urlencode(myMessage)

outData = host & "?username=" & myUsername & "&password=" & myPassword & "&mobile=" & myMobile & "&message=" & myMessage

set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.open "POST", outData, false
xmlhttp.send ""
resp = xmlhttp.responseText

response.write(resp)

set xmlhttp = nothing
C# VIEW SOURCE
public class API_DivaTxtSMS
{
    public string sendSMS(string APIusername, string APIpassword, string recipientMobile, string message)
    {
        string responseData = "";
        string method = "POST";
        string URL = "http://www.divatxt.co.uk/api/htpost.php";
        string postData = "username=" + APIusername + "&password=" +
            APIpassword + "&mobile=" +
            recipientMobile + "&message=" +
           HttpUtility.UrlEncode(message);
        try
        {
            System.Net.HttpWebRequest hwrequest =
              (System.Net.HttpWebRequest)System.Net.WebRequest.Create(URL);
            hwrequest.Accept = "*/*";
            hwrequest.AllowAutoRedirect = true;
            hwrequest.UserAgent = "http_requester/0.1";
            hwrequest.Timeout = 60000;
            hwrequest.Method = method;
            if (hwrequest.Method == "POST")
            {
                hwrequest.ContentType = "application/x-www-form-urlencoded";
                System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
                byte[] postByteArray = encoding.GetBytes(postData);
                hwrequest.ContentLength = postByteArray.Length;
                System.IO.Stream postStream = hwrequest.GetRequestStream();
                postStream.Write(postByteArray, 0, postByteArray.Length);
                postStream.Close();
            }
            System.Net.HttpWebResponse hwresponse =
              (System.Net.HttpWebResponse)hwrequest.GetResponse();
            if (hwresponse.StatusCode == System.Net.HttpStatusCode.OK)
            {
                System.IO.Stream responseStream = hwresponse.GetResponseStream();
                System.IO.StreamReader myStreamReader =
                  new System.IO.StreamReader(responseStream);
                responseData = myStreamReader.ReadToEnd();
            }
            hwresponse.Close();
        }
        catch (Exception e)
        {
            responseData = "An error occurred: " + e.Message;
        }
        return responseData;
    }
}

Usage:
API_DivaTxtSMS api = new API_DivaTxtSMS();
string responseData = api.sendSMS("myAPIUsername", "myAPIPassword", "myMobileNumber", "Test message sent using API");
VB VIEW SOURCE
Function sendDivaTxtSMS(ByVal APIusername As String, ByVal APIpassword As String, ByVal recipientMobile As String, ByVal message As String) As String
        Dim responseData As String = ""
        Dim URL As String = "http://www.divatxt.co.uk/api/htpost.php"
        Dim method As String = "POST"
        Dim POSTdata As String = "username=" + APIusername _
    + "&password=" + APIpassword _
    + "&mobile=" + recipientMobile _
    + "&message=" + System.Web.HttpUtility.UrlEncode(message)

        Try
            Dim hwrequest As Net.HttpWebRequest = Net.WebRequest.Create(URL)
            hwrequest.Accept = "*/*"
            hwrequest.AllowAutoRedirect = True
            hwrequest.UserAgent = "http_requester/0.1"
            hwrequest.Timeout = 60000
            hwrequest.Method = method
            If hwrequest.Method = "POST" Then
                hwrequest.ContentType = "application/x-www-form-urlencoded"
                Dim encoding As New System.Text.UTF8Encoding()
                Dim postByteArray() As Byte = encoding.GetBytes(POSTdata)
                hwrequest.ContentLength = postByteArray.Length
                Dim postStream As IO.Stream = hwrequest.GetRequestStream()
                postStream.Write(postByteArray, 0, postByteArray.Length)
                postStream.Close()
            End If
            Dim hwresponse As Net.HttpWebResponse = hwrequest.GetResponse()
            If hwresponse.StatusCode = Net.HttpStatusCode.OK Then
                Dim responseStream As IO.StreamReader = _
                  New IO.StreamReader(hwresponse.GetResponseStream())
                responseData = responseStream.ReadToEnd()
            End If
            hwresponse.Close()
        Catch e As Exception
            responseData = "An error occurred: " & e.Message
        End Try
        Return responseData
    End Function

Usage:
sendDivaTxtSMS("myAPIUsername", "myAPIPassword", "myMobileNumber", "Test message sent using API")
MICROSOFT VISUAL BASIC VIEW SOURCE
Sub DivaTxtSendSMS()
    Dim api As Object
    Dim responseData$
    Dim sUserName As String
    Dim sPassword As String

    sUserName = "myAPIUsername"
    sPassword = "myAPIPassword"
    sMobile = "myMobileNumber"
    sMessage = "Test message sent using API"
    'IMPORTANT! - to avoid errors message has to be URL encoded. There is no built in VBA function for this purpose however,
    ' you should be able to find a custom made one on the internet

    URL = "http://www.divatxt.co.uk/api/htpost.php"

    Set api = CreateObject("WinHttp.WinHttpRequest.5.1")
    api.Open "POST", URL, False
    api.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"

    responseData = "username=" & sUserName & "&password=" & sPassword & "&mobile=" & sMobile & "&message=" & sMessage
    ' Send the request to the web site
    api.send (responseData)

    ' Output the response
    MsgBox (api.responseText)
    Set api = Nothing
End Sub

Programming code examples - RECEIVING

PHP VIEW SOURCE
// dont proceed unless its a POST
if(isset($_POST["message"])) {
	$sender     = $_POST["sender"];
	$message    = $_POST["message"];
	$keyword    = $_POST["keyword"];
	$recipient  = $_POST["recipient"];
	$message_id = $_POST["message_id"];

	// handle message e.g. just save to a file
	$filename = "/tmp/inbound_log.txt";
	$fd = fopen($filename, "a");
	fwrite($fd,$sender."\n");
	fwrite($fd,$keyword."\n");
	fwrite($fd,$message."\n");
	fwrite($fd,$recipient."\n");
	fwrite($fd,$message_id."\n");
	fwrite($fd,"--------------\n");
	fclose($fd);

	// say something back so Diva can see something in the logs
	echo "Received ".$message_id . " OK";
}
outboundoutbound

OUTBOUND SMS

Instantly connect with your audience
LEARN MORE
inboundinbound

INBOUND SMS

Need a response from your audience or campaign?
LEARN MORE
email2smsemail2sms

EMAIL TO SMS

Communicate using a familiar interface
LEARN MORE
apiapi

API DEVELOPERS

Bring the world of texting to your applications
LEARN MORE
pricingpricing

PRICING

Minimum cost, maximum reliability
LEARN MORE
Leeds chamber of commerceLeeds chamber of commerce

Leeds Chamber Offers

Leeds Chamber members can benefit from these exclusive offers from our range...
LEARN MORE

BASKET

0
YOUR BASKET IS EMPTY

Need a UK Number?

PURCHASE NOW

Need an SMS Account?

SIGN UP

Need to make a Conference Call?

GET PIN

Log into our portal

LOGIN

LOG IN
CONTACT

© DIVA TELECOM 2014

TERMS & POLICIES
LEGAL NOTICES
PROFESSIONAL MEMBERSHIPS
SITE MAP