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.
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:
01
<html>
02
<head>
03
<META HTTP-EQUIV=
"CONTENT-Type"
CONTENT=
"text/html;CHARSET=utf-8"
>
04
<title>ActiveXperts SMS Messaging Server
05
PHP Sample</title>
06
</head>
07
08
<body>
09
10
<form method=
"get"
>
11
<input type=
"submit"
name=
"submit"
value=
"Kirim"
>
12
</form>
13
14
<?php
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
?>
59
</body>
60
</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.
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
- I create a new folder name sms within www/test directory.
No comments:
Post a Comment