Skip to content
Tags

, , ,

PHP PDU Class – (Send SMS with PHP)

by Vincent on June 22nd, 2010

For a project I wanted to send SMS messages with PHP. I figured a few things out that I will discuss in this blogpost. But the most important thing is the first release of the PHP PDU Class.

Sending SMS messages with PHP

The first thing I needed was a device to send a SMS to the cellular network, also know as a cellphone. I connected this phone to my server by Bluetooth. Then I established a connection between the cellphone and the server over Bluetooth so I could send AT commands to the phone. These AT commands make it possible to talk to the internal modem of a cellphone, for example to send a SMS. More information about AT commands can be found on these pages:

Let’s assume you have a working connection to your cellphone and understand what AT commands are. Now you need a way to convert a text message like “Hello!” into a PDU formatted string. Converting this text message to PDU can be difficult. So I wrote a text to PDU conversion script in the form of a PHP class. In this blog post I want to share this class with you. If a lot of people want me to detail the full “PHP to cellphone” setup I will write an blog post about it later on.

PHP PDU class

The PHP PDU class provides you an easy way to convert text messages to PDU formatted strings. The only thing you have to do is fill the message and the receiving cellphone number. The PHP PDU class will convert these parameters to the PDU format.

Example usage: (a more detailed example is in the download)
<?php
$pduGenerator = new Pdu();
$pduMessage = $pduGenerator->generatePDU('0612345678', 'This is a text message.');
?>

Because each cellphone has it’s own implementation of the PDU format the returned PDU message may not work for you. I tested this class with a Sony Ericsson cellphone, which worked great. But it is possible that you need to modify the class for other cellphone brands. If you do, please share these modifications in the comments along with the cellphone brand and model type.

More information about the PDU format:

Feel free to give me tips and feedback on the code. I wrote this script a long time ago, so it could be improved. I hope you like it.

Download

Download the PHP PDU class. (PHP PDU 1.0.tgz)
MD5 Hash: c181815c10707440edd8a1dd2b392cb8

License

Commercial use of this class is not allowed. If you like to use this code in any kind of commercial way or need this code under any other license please contact me.

PHP PDU by Vincent Heet is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Netherlands License.
Based on a work at adevelopersblog.com.
Creative Commons License

From → PHP

5 Comments
  1. Hey man great job there!

  2. Nice post! It really helped me to build my project. Thanks!

  3. However, can you also include the SMS Centre and other optional parameters?

  4. Vincent permalink

    I’m sorry I don’t have SMS center information for you. In my setup I talked to the phone by AT commands and the phone had a default SMS center from the operator.

Trackbacks & Pingbacks

  1. 8-bit SMS PDU Encoding via PHP - Nicholas Skinner’s Blog

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS