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:
- Download sms messaging server at www.activexperts.com.
- Install, just follow the instruction along with installation proccess.
- After installation, open ActiveXperts SMS Messaging Server Manager.
- Now, we want to migrate database to mysql. Just click item Database Migration at Server tools in left menu panel.
- Choose MySQL Server. Then, follow instruction. It is realy simple.
- 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:
11"submit"name="submit"value="Kirim">12131415if($_GET['submit']){16$objConstants=newCOM ("AxSmsServer.Constants");17$objMessageDB=newCOM ("AxSmsServer.MessageDB");1819$objMessageDB->Open ();2021if($objMessageDB->LastError <> 0 )22{23$ErrorDes=$objMessageDB->GetErrorDescription ($objMessageDB->LastError );2425die($ErrorDes);26}2728$objMessage=$objMessageDB->Create ();2930if($objMessageDB->LastError <> 0 )31{32$ErrorDes=$objMessageDB->GetErrorDescription ($objMessageDB->LastError );3334die($ErrorDes);35}3637$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";4445// Save the Message4647$objMessageDB->Save ($objMessage);4849if($objMessageDB->LastError <> 0 )50{51$ErrorDes=$objMessageDB->GetErrorDescription ($objMessageDB->LastError );5253die($ErrorDes);54}5556Echo"Successfully created new SMS Message";57}58?>
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:
Post a Comment