How to send SMS from a website?

Posted by Aamir khan

The example I present here shows how to send an SMS message from your website by clicking on a button. The idea we use is to have an HTML form, that allows the website visitor to enter a phone number and the message text. This HTML form can be submitted by clicking on the "SEND" button. Once submitted the form variables will be processed by a PHP script. This PHP script will post the SMS message to the SMS Gateway (Figure 1). As you can see on Figure 1. The SMS Gateway and your webserver (your webserver is hosting your HTML Form and your PHP script) can be on two different computers. If you wish you can install the Ozeki SMS Gateway software and the webserver with the HTML Form and the PHP script to the same computer.

Send SMS from a website

Figure 1 - Send SMS from a website

The first step in setting up this system, is to Install the Ozeki NG SMS Gateway to your computer and to verify, that you can send SMS messages from the gateway manually. After your SMS gateway is functioning you can create the HTML Form and the PHP script.

Ozeki NG SMS Gateway can be obtained by
opening the download page:
Download Ozeki NG SMS Gateway!

Create the HTML Form for sms sending

To get this solution working you need to save the sendsms.html file into the WWW directory of your webserver. The sendsms.html file will contain the HTML Form that can be used to get the recipient telephone number and the message text from the website visitors. Here is the source of the sendsms.html file:

C:\www\sendsms.html

My SMS form

Recipient
Message
After you save this file, you can use a browser (Internet Explorer or Firefox) to open it (Figure 2). On the form you will seen an input box for the recipient field and the message text. The recipient field will take the telephone number (e.g. +4407776134588) and the message field will take the message text.


Figure 2 - open the SMS form in your browser
Please note that the form action tag points to the sendsms.php file. This means that the data entered by the website visitor will be posted to the sendsms.php file.

Prepare your PHP SMS script

As you can see the form target in this HTML form is the sendsms.php. The sendsms.php script will get the recipient and the message fields from the form and will build a URL to send the SMS message. This URL will be used to pass the SMS message to the SMS gateway. The URL is invoked in the PHP script using the file command. To get this script working you should configure the $ozeki_url variable to point to the SMS gateway. If you have installed the SMS Gateway to the same computer where your webserver is you can leave this untouched, otherwise you should change the IP address in the URL. The source code of the script is here:

C:\www\sendsms.php
$urltouse

"; }        //Open the URL to send the message 
$response = httpRequest($urltouse);
if ($debug) {            echo "Response: 
". str_replace(array("<",">"),array("<",">"),$response).            "
"; } return($response); } 
######################################################## # 
GET data from sendsms.html 
######################################################## 
$phonenum = $_POST['recipient']; $message = $_POST['message'];
$debug = true;  ozekiSend($phonenum,$message,$debug);  ?> 
Once you have both: sendsms.html and sendsms.php installed, you can submit an SMS to the gateway. On a successful send the SMS gateway will return the message reference number (Figure 3). This number can be used to track the message inside the SMS Gateway.


Figure 3 - Successful SMS sending

Useful information

In order to be able to use this PHP script, you need to have the Ozeki NG SMS Gateway software installed to your computer. After Ozeki NG SMS Gateway is installed and configured, change the value of the $ozeki_url variable in the above PHP script to reflect the IP address of your computer. In other words, if you install Ozeki NG SMS Gateway to the computer, that has an IP address of 101.102.103.104, you should change the http://127.0.0.1:9501/api? value to http://101.102.103.104:9501/api?. Note that the ip address 127.0.0.1 has been changed in the $ozeki_url variable.

{ 204 comments... read them below or add one }

«Oldest   ‹Older   201 – 204 of 204   Newer›   Newest»
Anonymous said...

Samsung Libre C3300 Sony-Ericsson K800i Sony Ericsson W610i myway.com lavsasisa tragsymnomu luhihachec infoseek.co.jp Sony Ericsson W595 overture.com provustialya napongobbspel acmoipleatcirc Copyright.gov Motorola M3188 Philips 292 Handyuhr iWatch EG100

Anonymous said...

Sagem MY X-5 NEC N100 Casio c303ca tribalfusion.com quiroumary highdesuppers minstimisde yieldmanager.com Nokia 6125 ebay.com.cn musckidardio topluwimdie rcifavhebe daum.net LG KP501 Siemens AX72 O2 Cocoon

Anonymous said...

[url=http://extrasun.ru/Prodaja.html][img]http://extrasun.ru/components/com_joomgallery/img_thumbnails/_1/_20121130_1355800611.jpg[/img][/url]
Стоимость обогревателя «SIRIUS» выгодно отличается от представленных на рынке аналогов. Наша конкурентная цена - это оптимальное соотношение в сочетании с высоким качеством. [url=http://extrasun.ru/preimushestva.html] Новое поколение уличных обогревателей - обогреватели “SIRIUS”с живым пламенем, покорившие рынки США, Канады и Европы теперь в России![/url]
Уличные газовые обогреватели "SIRIUS" идеальное решение для заведений с открытыми, полузакрытыми верандами и террасами, безопасный и экономичный способ создать теплую зону на дачных террасах и в беседках.

Anonymous said...

Hello. And Bye.

Post a Comment

What you Says

..-

Related Posts Plugin for WordPress, Blogger...

If you like this blog,then link back to me.
This is what you will see.



Optionally use this Widget installer to add this link to your blogger blog.