You are here:
ActiveXperts.com > SMS and MMS Toolkit > How to Use the SMS and MMS Toolkit > HTTP/SMS > PHP
Quicklinks
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:
MMS features:
Pager features:
This document describes how the SMS and MMS Toolkit can be integrated into PHP projects.
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.
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");
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.