On 1/1/2020, Auron Software B.V. acquired ActiveXperts SMS Component and will continue developing, selling and supporting the product under it's own brand name Auron SMS Component. Maintenance contracts will be continued directly by Auron Software as of 1/1/2020.

PHP sample - Send SMS text through an HTTP provider

The ActiveXperts SMS Component is a software development kit (SDK) to enhance an application or script with SMS or Pager functionality. SMS messages can be sent/received using a GSM modem, an SMPP provider or an HTTP compliant SMSC.


In this example we are going to create a PHP page to send SMS messages. This demo project will ask the user to give a phone number and a message body in the web interface.

A subscription to an HTTP provider is required. For this demo you can send a limited number of messages through our own gateway.

Step 1: Installation of the ActiveXperts SMS Component

On each client PC, download the ActiveXperts SMS Component from the ActiveXperts Download Site and start the installation. The installation guides you through the installation process.

Step 2: Declare and create the ActiveXperts SMS Component objects

You must use the following code to declare the COM object(s) in PHP:

$objHttp           = new COM("AxSms.Http"); 
$objSmsMessage     = new COM("AxSms.Message"); 
$objSmsConstants   = new COM("AxSms.Constants");

Step 3: Gathering information

The following code will ask the user for the recipient telephone number and the content of the text message. This data will be stored in the 'objSmsMessage' object.

$objSmsMessage->BodyFormat = $objSmsConstants->BODYFORMAT_UNICODE;      
$objSmsMessage->Body = $_POST['txtBody'];
$objSmsMessage->ToAddress = $_POST['txtToAddress'];

Step 4: Send SMS messages

The following code shows how to send an SMS message using the data that was stored in the 'objSmsMessage' and 'objSmsConstants' objects.

$obj = $objSmsMessage;
$objHttp->SendSms($obj, $objSmsConstants->MULTIPART_OK);

Appendix: Full source code

Following you can find the full source code which is also included in the ActiveXperts SMS Component package.

  $strResult = "n/a";
  $strLastResponse = "";
  $objHttp           = new COM("AxSms.Http");    
  $objSmsConstants   = new COM("AxSms.Constants");    
  $objHttp->LogFile  = sys_get_temp_dir()."ActiveXperts.Http.log"; 
  //Windows default: 'C:\Windows\Temp\ActiveXperts.Http.log'
  //Form submitted
  if (isset($_POST["btnSendMessage"]))
    $objSmsMessage = new COM("AxSms.Message");      
    $objSmsMessage->BodyFormat = $objSmsConstants->BODYFORMAT_UNICODE;      
    $objSmsMessage->Body = $_POST['txtBody'];
    $objSmsMessage->ToAddress = $_POST['txtToAddress'];
    $objHttp->Url = $_POST['txtUrl'];
    $obj = $objSmsMessage;
    $objHttp->SendSms($obj, $objSmsConstants->MULTIPART_OK);
    $strResult = $objHttp->LastError . ": " . $objHttp->GetErrorDescription($objHttp->LastError);
    $strLastResponse = $objHttp->LastResponseCode;
<html xmlns="http://www.w3.org/1999/xhtml" >
    <title>ActiveXperts SMS Component Demo</title>
      </div><!-- /header -->
        <h1>SMS Component PHP HTTP Sample</h1>
        <hr />
          The HTTP protocol is used for medium volume SMS messaging. Messages are first 
          routed to the service provider via Internet/VPN. The provider delivers the 
          messages to the recipient's phone. If you are not subscribed to a provider, use 
          the ActiveXperts gateway to send 10 SMS messages for free.
        <form action="http.php" method="post">
          <h2>SMS Component:</h2>
          <h3>Build: <?php echo $objHttp->Build; ?>; Module: <?php 
          echo $objHttp->Module; ?></h3>
          <!-- Connection URL -->
          <label for="Url">Connection URL:</label>
            <?php $strInfo = "post.activexperts-labs.com:8080/sendsms/default.asp" .
                             "?username=myUsername" . 
                             "&password=myPassword" . 
                             "&text=".$objSmsConstants->HTTP_PLACEHOLDER_BODY . 
            <input type="text" id="Url" name="txtUrl" value="<?php echo 
            $strInfo ?>" />
          <!-- ToAddress -->
          <label for="ToAddress">ToAddress:</label>
            <input type="text" id="ToAddress" name="txtToAddress" value="[ToAddress]" />
            <a href="https://www.activexperts.com/support/sms-component/?kb=Q4200015" 
                target="_blank">Recipient number format</a>

          <!-- Body -->
          <label for="Body">Body:</label>
              <textarea id="Body" name="txtBody" style="height:55px;">
                Hello world send from ActiveXperts SMS Component!
          <!-- Send button -->
            <input type="submit" name="btnSendMessage" value="Send SMS Message!" />
          <!-- Result -->
          <label for="Result"><b>Result:</b></label>
            <input type="text" id="Result" name="txtResult 
              value="<?php echo $strResult; ?>" />
          <!-- Last Response -->
          <label for="Response">Last Response:</label>
            <input type="text" id="Response" name="txtLastResponse" 
              value="<?php echo $strLastResponse; ?>" />
      </div><!-- /container -->
    </div><!-- /maincontainer -->

You can download the full source code of this project from the ActiveXperts FTP site: ftp.activexperts-labs.com/samples/sms-component. There are many other working samples included with the product or on the FTP site.

NOTE: Demo Projects are created with Microsoft Visual Studio 2008

The ActiveXperts SMS Component project ships with a set of Microsoft Visual Studio .NET samples. The projects are created with Microsoft Visual Studio 2008.

Users with a later version of Microsoft Visual Studio can open such a project. The Visual Studio Conversion Wizard will guide you through the process of converting the project to the version used.