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"
>
12
13
14
15
if
(
$_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
?>
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