phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


SMS : Line Codes Send Simple SMS (Part 2)

Tag: sms   Category: PHP Application
post: 05 Dec 2007 read: 1,746


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:
    
    <html>
    <head>
    <META HTTP-EQUIV="CONTENT-Type" CONTENT="text/html;CHARSET=utf-8" >
    <title>ActiveXperts SMS Messaging Server 
    PHP Sample</title>
    </head>
    
    <body>
    
    <form method="get">
    <input type="submit" name="submit" value="Kirim">
    </form>
    
    <?php
    if($_GET['submit']){
      $objConstants = new COM ( "AxSmsServer.Constants" );
      $objMessageDB = new COM ( "AxSmsServer.MessageDB" );
       
      $objMessageDB->Open ();
       
      if ( $objMessageDB->LastError <> 0 )
      {
        $ErrorDes = $objMessageDB->GetErrorDescription ( $objMessageDB->LastError );
    
        die ( $ErrorDes );
      }
    
      $objMessage = $objMessageDB->Create ();
    
      if ( $objMessageDB->LastError <> 0 )
      {
        $ErrorDes = $objMessageDB->GetErrorDescription ( $objMessageDB->LastError );
    
        die ( $ErrorDes );
      }
       
      $objMessage->Direction     = $objConstants->MESSAGEDIRECTION_OUT;
      $objMessage->Type          = $objConstants->MESSAGETYPE_SMS;
      $objMessage->Status        = $objConstants->MESSAGESTATUS_PENDING;
      $objMessage->ChannelID     = 0;
      $objMessage->ScheduledTime = ""; 
      $objMessage->Recipient     = "+6281328562xxx";
      $objMessage->Body          = "SMS Messaging Server - PHP Test SMS";
    
      // Save the Message
     
      $objMessageDB->Save ( $objMessage );
    
      if ( $objMessageDB->LastError <> 0 )
      {
        $ErrorDes = $objMessageDB->GetErrorDescription ( $objMessageDB->LastError );
    
        die ( $ErrorDes );
       }
    
      Echo "Successfully created new SMS Message";
    	}
       ?>
       </body>
    </html>
    

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.



Series this article:
SMS : Sending SMS with PHP and ActiveXperts (Part 1)
SMS : Line Codes Send Simple SMS (Part 2)

| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
mod_rewrite - Part 1: create your "fantasy" URL

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting