SMS : Line Codes Send Simple SMS (Part 2)
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!!!
- I create a new folder name sms within www/test directory.
- Then, create a new file name smstest.php within sms folder.
- 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) Tag: sms Category: PHP Application Post : December 05th 2007 Read: 4,674 blog comments powered by Disqus |
