How can we help?

Programming examples


Call the HTTP REST API from any programming language that supports HTTP calls.

The programming examples below use the HTTP REST API to retrieve version information.

@REM This curl sample demonstrates how to get SMS Server version information
@REM using the Auron SMS Server HTTP API.
@REM 

SET API_PROTOCOL=http
SET API_HOST=localhost
SET API_PORT=7000
SET API_CHANNELID=HTTP_API1
SET API_AUTHORIZETOKEN=

SET BASEURL=%API_PROTOCOL%://%API_HOST%:%API_PORT%/%API_CHANNELID%/

curl -H "Content-Type: text/json" -H "Authorization: %API_AUTHORIZETOKEN%" ^
  %BASEURL%/messagedb/version.json
# This Powershell sample demonstrates how to get SMS Server version information
# using the Auron SMS Server HTTP API.
# 

$API_PROTOCOL       = "http"
$API_HOST           = "localhost"
$API_PORT           = 7000
$API_CHANNELID      = "HTTP_API1"
$API_AUTHORIZETOKEN = ""

$BASEURL = "${API_PROTOCOL}://${API_HOST}:${API_PORT}/${API_CHANNELID}/"

$objResponse = Invoke-RestMethod -Uri "${BASEURL}/messagedb/version.json"
Write-Host "Version:" $objResponse.result[0].Version 
Write-Host "Build:" $objResponse.result[0].Build
<?php  
  //  This PHP sample demonstrates how to get SMS Server version information
  //  using the Auron SMS Server HTTP API.
  //  
  
  $API_PROTOCOL       = "http";
  $API_HOST           = "localhost";
  $API_PORT           = "7000";
  $API_CHANNELID      = "HTTP_API1";
  $API_AUTHORIZETOKEN = "";
  
  $BASEURL = $API_PROTOCOL . "://" . $API_HOST . ":" . $API_PORT . 
     "/" . $API_CHANNELID . "/";
  
  // Get version information
  $url = $BASEURL . "/messagedb/version.json";
  $options = array(
      'http' => array(
          'method'  => 'GET'
      )
  );
  $context  = stream_context_create($options);
  $result = file_get_contents($url, false, $context);
  if ($result === FALSE) 
  {
    echo("<h2 style='color: #f00;'>Error while connecting to HTTP API. " . 
      "Please make sure you have an HTTP API channel configured.</h2>");      
    exit;
  } else
    $json = json_decode($result);
  
  // decode
  $smsserver_version = $json->result[0]->Version;
  $smsserver_build = $json->result[0]->Build;    
?>
<html>
   <head>
   <META HTTP-EQUIV="CONTENT-Type" CONTENT="text/html;CHARSET=utf-8" >
   <title>Auron SMS Server - PHP HTTP API Sample</title>
   </head>
   <body>
   <h1>Auron SMS Server - PHP HTTP API Sample</h1>
   <h3>Version [<?php echo($smsserver_version); ?>]; 
       Build [<?php echo($smsserver_build); ?>]</h3>
   </body>
</html>
// This C# sample demonstrate how to get SMS Server version information using
// the Auron SMS Server HTTP API.
//

namespace CreateMessage
{
  class Program
  {
    private const string API_PROTOCOL = "http";
    private const string API_HOST = "localhost";
    private const string API_PORT = "7000";
    private const string API_CHANNELID = "HTTP_API1";
    private const string API_AUTHORIZETOKEN = "";

    private const string BASEURL = API_PROTOCOL + "://" + API_HOST + ":" + API_PORT + 
        "/" + API_CHANNELID + "/";

    static void Main(string[] args)
    {
      HttpClient oHttpClient = new HttpClient();
      oHttpClient.BaseAddress = new Uri(BASEURL);
  
      if (API_AUTHORIZETOKEN != "")
        oHttpClient.DefaultRequestHeaders.Authorization = 
           new AuthenticationHeaderValue(API_AUTHORIZETOKEN);

      XmlDocument oXml = new XmlDocument();
      
      // Get SMS Server version
      var oResponse = oHttpClient.GetAsync("messagedb/version.xml").Result;
      if (!oResponse.IsSuccessStatusCode)
      {
        Console.WriteLine("Error while getting version information.");
        return;
      }

      // Print version information
      string sVersionData = oResponse.Content.ReadAsStringAsync().Result;
      oXml.LoadXml(sVersionData);
      Console.WriteLine("Version: " + oXml.SelectSingleNode("//Version[1]").InnerText);
      Console.WriteLine("Build: " + oXml.SelectSingleNode("//Build[1]").InnerText);
      Console.WriteLine("");
    }
  }
}
' This VBScript sample demonstrate how to get SMS Server version information
' using the Auron SMS Server HTTP API.
' 

Const API_PROTOCOL = "http"
Const API_HOST = "localhost"
Const API_PORT = "7000"
Const API_CHANNELID = "HTTP_API1"
Const API_AUTHORIZETOKEN = ""

Set objHttp = CreateObject("Microsoft.XmlHttp")
Set objXml = CreateObject("MSXML2.DOMDocument.6.0")

sBaseUrl = API_PROTOCOL & "://" & API_HOST & ":" & API_PORT & "/" & API_CHANNELID & "/"
sUrl = sBaseUrl & "messagedb/version.xml"
objHttp.open "GET", sUrl, false

objHTTP.SetRequestHeader "Content-Type", "text/xml"
If API_AUTHORIZETOKEN <> "" Then
  objHTTP.SetRequestHeader "Authorization", API_AUTHORIZETOKEN
End If  

objHttp.send
objXml.LoadXML objHttp.responseText

WScript.Echo "Version: " & objXml.SelectSingleNode("//Version[1]").text
WScript.Echo "Build: " & objXml.SelectSingleNode("//Build[1]").text & vbCrLf