ActiveXperts SMS and MMS Toolkit Add SMS and MMS capabilities to any Windows or .NET application

Using the SMS and MMS Toolkit with PHP

The SMS and MMS Toolkit is a software development kit (SDK) to enhance an application or script with SMS, MMS and Pager functionality. SMS messages can be sent using a GSM/GPRS modem, an SMPP provider, an HTTP compliant SMS provider or using a standard dialup or fixed-line SMS modem. MMS messages can be sent via a GSM/GPRS modem (MM1), an SMTP server (MM4) or an XML/SOAP compliant provider (MM7).

SMS features:

  • Send and receive numeric- and alphanumeric text SMS messages
  • Verify delivery of outgoing SMS messages
  • Support for multimedia SMS messages, including ringtones, pictures and logo's
  • Support for WAP Push, WAP Bookmarks, vCards, voicemail/e-mail/fax/MMS indications
  • Support for Unicode, to support foreign languages like Arabic, Chinese, Hebrew, etc.
  • Support for multi-part messages, to allow messages longer than 160 characters
  • Support for GSM modems, GSM phones, SMS/HTTP providers, SMPP (Short Message Peer to Peer) providers, TAP/XIO and UCP dial-in SMSC providers
  • Support Multi-threading environments. The component is thread-safe, which means it can be used in a multi-threaded environment
  • Samples included for various development platforms: MS Visual Basic, MS Visual Basic .NET, MS Visual C++, MS Visual Studio C# .NET, ASP, ASP .NET, Borland Delphi, Borland C++ Builder, Windows Powershell ColdFusion and more

MMS features:

  • Support for many multimedia formats incl.: JPG, GIF, PNG, BMP, WBMP, TIF, WAV, MP3, MIDI, AC3, GP3, AVI, MPG, MP4, VCARD, VCALENDAR, JAR and more
  • Support for MM1 (MMS over WAP), MM4 (MMS over SMTP) and MM7 (MMS over HTML/SOAP)

Pager features:

  • Send alpha-numeric Pager messages through SNPP

This document describes how the SMS and MMS Toolkit can be integrated into PHP projects.

Step 1: Installation of the SMS and MMS Toolkit

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

Step 2: Create the SMS objects in PHP

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

Use the following PHP code to declare and create the objects:

$objHttpProtocol  = new COM ("ActiveXperts.SmsProtocolHttp");
$objSmsMessage    = new COM ("ActiveXperts.SmsMessage");
$objSmsConstants  = new COM ("ActiveXperts.SmsConstants");

Step 3: Send and/or receive SMS messages

You can now send and/or receive SMS messages.

The following PHP code shows how to send a SMS through an HTTP SMS Gateway:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<? 

if($_POST['submitbutton'] != "" ){

      //Set the objects
      $objHttpProtocol                          = new COM ("ActiveXperts.SmsProtocolHttp");
      $objSmsMessage                            = new COM ("ActiveXperts.SmsMessage");
      $objSmsConstants                          = new COM ("ActiveXperts.SmsConstants");

      // Set provider properties
      $objHttpProtocol->ProviderHost            = "post.activexperts-labs.com";
      $objHttpProtocol->ProviderPort            =  8080;
    
      //Provider Response templates
      $objHttpProtocol->ProviderErrorResponse   = "ERR";         // Response should NOT contain: 'ERR'
      $objHttpProtocol->ProviderSuccessResponse = "id";          // Response should contain:     'id'

      // Set URL templates
      $objHttpProtocol->URLText                 = "/sendsms/default.asp?username=AX008&password=812056&text=%MESSAGEDATA%&to=%MESSAGERECIPIENT%&from=%MESSAGESENDER%";
      $objHttpProtocol->URLBinary               = "/sendsms/default.asp?username=AX008&password=812056&text=%MESSAGEDATA%&to=%MESSAGERECIPIENT%&from=%MESSAGESENDER%&data=1";
      $objHttpProtocol->URLUnicode              = "/sendsms/default.asp?username=AX008&password=812056&text=%MESSAGEDATA%&to=%MESSAGERECIPIENT%&from=%MESSAGESENDER%&unicode=1";

      // Set message properties
      $objSmsMessage->Sender                    =  $_POST["phonenumberSender"];
      $objSmsMessage->Data                      =  $_POST["message"];			

      //set message type
      if ( $_POST['unicode'] == "on" ){
        $objSmsMessage->Format                  = $objSmsConstants->asMESSAGEFORMAT_UNICODE;
      }
      else{
        $objSmsMessage->Format                  = $objSmsConstants->asMESSAGEFORMAT_TEXT;			
      }
	
      $objSmsMessage->Recipient                 = $_POST['phonenumber'];

      // Set Logfile
      $objHttpProtocol->LogFile                 = "C:\\SmsLogPhp.txt";
      
      // Send sms!
      if($objHttpProtocol->LastError == 0){
        $objHttpProtocol->Send( objSmsMessage );
      }
			
      $result = $objHttpProtocol->GetErrorDescription($objHttpProtocol->LastError);

// end if submitbutton != ""
}			
?>

<html>
<head>
  <title>ActiveXperts SMS and MMS Toolkit sample in PHP</title>
   <style type="text/css">
   <!--
     body{
        background-color: white;
        text-align: center;
     }
     input{
        width: 200px;
        border: 1px solid black;
        background-color: white;
     }
     textarea{
        width: 200px;
        border: 1px solid black;
        background-color: white;
        height: 100px;
     }		 
     table{
        width: 430px;
        border: 1px solid black;
        font-family: verdana;
        font-size: x-small;
     }
     h2{
        font-size: normal;
        font-family: verdana;
        font-weight: bold;
     }
     a{
        font-family: verdana;
        font-weight: bold;
        font-size: xx-small;
        color: red;
        text-decoration: none;
     }
     a:hover{
        text-decoration: underline;
     }
   -->
  </style>

</head>
<body>

<form method=post>
<h2><font size=3 color=red><b>ActiveXperts</b></font><br>SMS and MMS Toolkit<br>Http sample in PHP</h2>

<font size=1 face=verdana><b>Fill in the form to send an sms:<br>Note:</b></font>
<font size=1 color=red face=verdana><b> Dont forget to fill in the country code prefix!!</b></font>
<table>
  <tr>
    <td><b>Your phone-number:</b></td>
    <td width=200><input type=text name=phonenumberSender value="<? echo $_POST['phonenumberSender']; ?>"></td>
  </tr>
  <tr>
    <td><b>Recipients phone-number:</b></td>
    <td><input type=text name=phonenumber value="<? echo $_POST['phonenumber']; ?>"></td>
  </tr>
  <tr>
    <td><b>Unicode:</b></td>
    <td>
     <?
       if($_POST['unicode'] == "on"){
         echo '<input type=checkbox name=unicode style="width: 20px;" checked> Send message as unicode';
       }
       else{
         echo '<input type=checkbox name=unicode style="width: 20px;"> Send message as unicode';
       }			
     ?>
     </td>
  </tr>	
  <tr>
    <td valign=top><b>Message:</b></td>
    <td><textarea name=message><? echo $_POST['message']; ?></textarea></td>
  </tr>
  <tr>
    <td> </td>
    <td><input type=submit name=submitbutton value="Send SMS!"></td>
  </tr>
</table>
<br><br>
<font size=1 face=verdana><b>Results:</b></font>
<table>
  <tr>
    <td><b>Result:</b></td>
    <td><? echo $result; ?></td>
  </tr>
</table>
<font face=verdana target=new size=1>This is an <a href="http://www.activexperts.com">ActiveXperts</a> sample.</font>
</form>
</body>
</html>

There are many working samples included with the product. You can also find them on the ActiveXperts FTP site: ftp.activexperts-labs.com/samples/mobile-messaging-component.