How To: Created 2 Way SMS Gateway With NowSMS and PHP

I believe this topic is good for application developers. In this short article we will learn how to created SMS gateway and applied it on worldwide-web using PHP script. What is SMS? SMS stands for short message service. It’s the text communication service component of phone or mobile communication systems, using standardized communications protocols that allow the exchange of short text messages between fixed line or mobile phone devices… more details about SMS please read in wikipedia.

I already written about how to build SMS gateway on my “Bahasa Indonesia” blog, but many people give negative comment on that article because that article is just illustration without real product. There is nothing goes wrong on that article, everything has requirement to created SMS gateway. I think people commenting negative on that article because they never use their brain to “think outside the box“.

Here is image illustration how SMS and Internet can be combined, this application can created a better experience for end users :

Enough for my bad introduction, before we start to learn how to created real SMS gateway we need some requirements in here:

  1. An computer to act as gateway and web-server.
  2. One or more Phone/Modem+SIM cards to act as connection between your SMS gateway and your provider.
  3. NowSMS program (60 days trials or buy) act as virtual machine to send and received SMS.
  4. Web hosting with PHP support (needed when you want to created an online worldwide-web application).
  5. An knowledge to solve a little problem.

First, we have to make our computers to be a web-server. I recommended to use XAMPP. It works on windows/linux operating system. Use your knowledge to solve all problem you may faced on this step, no need to ask me everything 🙂 You may have to setting port forwarding on your router if necessary.

Next step is connecting your phone/modem to your computer. You can use USB-Cable, Bluetooth, Infrared, or anything that can be used to connecting your phone into your computer. Use your knowledge to solve all problem on this step. In this sample I used USB-Cable.

Next step is installing NowSMS and configure it. After you install NowSMS run it, program should show this screen, next click on add.

Choose which one fit on your configuration and then click OK.

Choose modem installed on your computer, then click test and add modem. In many case, mostly the problem is you might can connecting your Phone but your phone didn’t support for SMS. You can solve this case by use USB-Cable connection.

When you success on add modem, this screen will shown. make sure you click on test button once again.

Click on properties and write down your phone number, you can write phone/modem PIN if it required.

Run this sms gateway service when you needed to send SMS from worldwide-web application.

Try it on your local computers, by default port for SMS gateway is 8800. So you have to write https://localhost:8800 to see this form.

After this step our SMS gateway are ready to use. Next step is created application via PHP script to let us sending SMS or received SMS from internet.

Received SMS

First we have to created an MySQL database to recorded all incoming message to our database. Created a new MySQL database and then import this code:

# CREATE TABLE `inbox` (
# `id` int(5) NOT NULL auto_increment,
# `msg` text NOT NULL,
# PRIMARY KEY (`id`)
# ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;

Next use this sample PHP script

# <?php
#
# // database
# $db_host = “localhost”;
# $db_user = “username”;
# $db_pass = “password”;
# $db_name = “database name”;
#
# // connect to mysql
# $link = mysql_pconnect ($db_host, $db_user, $db_pass) or die (“can’t connect”);
# mysql_select_db ($db_name) 0or die (“can’t select database”);
# $msg = trim($msg);
#
# //input to table inbox
# $sql = “INSERT INTO inbox
# SET id=”,
# msg=’$msg'”;
# $query = mysql_query($sql) ;
# ?>

Next step is configure setting on NowSMS program:

  1. Click 2-Way tab.
  2. Check Process Received SMS Messages
  3. Add SMS Command Prefix text, example: Idol (every SMS received with Idol prefix will added into database).
  4. Write your phone number on Receive Phone Number(s)
  5. Write http:/[yourdomainname]/[yourpath]/[email protected]@[email protected]@ to Command to Execute.
  6. Click Add then click Apply.

When we received message to this phone number with right prefix it will automatically recorded into our database, on next step we can use this database to any application we need example: vote SMS, etc. Please be creative!

Sending SMS

Next, how we created an simple script to send SMS message from our web-server? I was searching on google and found this good sample script. It might be useful to use. Read the full sample SMS script in here. Use your imagination and be creative!

Ending

That’s it, enough the lesson for today 🙂 If you like this script you can donate to me *LOL* I’m just kidding… If you want to test SMS application you can try this it would sending SMS message to all Indonesian GSM/CDMA network. Have a good day everyone :):)

Similar Posts:

RELATED SEARCH TERMS:

12 thoughts on “How To: Created 2 Way SMS Gateway With NowSMS and PHP”

  1. Hey, it is very useful for me. Thanks you so much. I am able to create two way sms gateway with my scripting language. Now it is very easy for me.

  2. Hi, I am having Parse error at line 10 (# $link = mysql_pconnect ($db_host, $db_user, $db_pass) or die (“can’t connect”);)

    Can you pls help…

  3. I love this post. I wonder if you can create a customer script for us. I am willing to pay for your work.. Thank you

    Please reply to my email if you are interested. Thank you

  4. Hello I am so excited I found your blog, I really found you by mistake, while I
    was searching on Askjeeve for something else, Anyhow I am here now and
    would just like to say thanks a lot for a marvelous post and a all round entertaining blog (I also love the theme/design), I
    don’t have time to read it all at the moment but I have bookmarked it and also
    added in your RSS feeds, so when I have time I will be back to read more, Please do keep
    up the excellent b.

  5. Yoou haνe made some really ood pointѕ
    there. I checked oո the internet for more information about
    the іssue anԁ fߋund most people will go аlong with yoսr views on thos site.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.