Subscribe

RSS Feed (xml)

SMS : Sending SMS with PHP and ActiveXperts

huif... I break almost 2 week for writing this blog. Actually not rest, busy with a project. Build academic information system for university :). Ok. Now, I continue with interesting topic: sending sms with PHP. My friends ask me how to send sms in PHP. They want to sell to radio programs or else. I ask, "Do You want a simple way or long way?". Most of them prefer simple way.
If we want simple way. We don't need build sms server self. Just using a product sms server like activexperts. You can download trial version before use it (at www.activexperts.com). This tutorial about using activexperts with php.
Before you instal, make sure you have devices: handphone (+ sim card) and data cable. You can follow installation important steps below:

  1. Download sms messaging server at www.activexperts.com.
  2. Install, just follow the instruction along with installation proccess.
  3. After installation, open ActiveXperts SMS Messaging Server Manager.
  4. Now, we want to migrate database to mysql. Just click item Database Migration at Server tools in left menu panel.
  5. Choose MySQL Server. Then, follow instruction. It is realy simple.
After install sms messaging server, now we will test with php. In this tutorial we just write simple code, just for testing. If it pass, we can continue with more complex project and sell it!!!

  1. I create a new folder name sms within www/test directory.
  2. Then, create a new file name smstest.php within sms folder.
  3. Enter following codes in that file:


    "get">
    11"submit" name="submit" value="Kirim">
    12
    13 
    14
    15if($_GET['submit']){
    16  $objConstants = new COM ( "AxSmsServer.Constants" );
    17  $objMessageDB = new COM ( "AxSmsServer.MessageDB" );
    18    
    19  $objMessageDB->Open ();
    20    
    21  if ( $objMessageDB->LastError <> 0 )
    22  {
    23    $ErrorDes = $objMessageDB->GetErrorDescription ( $objMessageDB->LastError );
    24 
    25    die ( $ErrorDes );
    26  }
    27 
    28  $objMessage = $objMessageDB->Create ();
    29 
    30  if ( $objMessageDB->LastError <> 0 )
    31  {
    32    $ErrorDes = $objMessageDB->GetErrorDescription ( $objMessageDB->LastError );
    33 
    34    die ( $ErrorDes );
    35  }
    36    
    37  $objMessage->Direction     = $objConstants->MESSAGEDIRECTION_OUT;
    38  $objMessage->Type          = $objConstants->MESSAGETYPE_SMS;
    39  $objMessage->Status        = $objConstants->MESSAGESTATUS_PENDING;
    40  $objMessage->ChannelID     = 0;
    41  $objMessage->ScheduledTime = "";
    42  $objMessage->Recipient     = "+6281328562xxx";
    43  $objMessage->Body          = "SMS Messaging Server - PHP Test SMS";
    44 
    45  // Save the Message
    46  
    47  $objMessageDB->Save ( $objMessage );
    48 
    49  if ( $objMessageDB->LastError <> 0 )
    50  {
    51    $ErrorDes = $objMessageDB->GetErrorDescription ( $objMessageDB->LastError );
    52 
    53    die ( $ErrorDes );
    54   }
    55 
    56  Echo "Successfully created new SMS Message";
    57    }
    58   ?>

You can change content of line 41 and 42. May, point this sms to your hp self. Change message with your words.
Point your browser to http://localhost/test/sms/smstest.php. You will get a button. Just click. Wait for seconds, if success, you will get message in your handphone from this application.

0 comments:

Related Posts with Thumbnails