PoiNtEr->: How to Send SMS With Kannel SMS and WAP gateway??

                             Difference between a dream and an aim. A dream requires soundless sleep, whereas an aim requires sleepless efforts.

Search This Blog

Friday, February 17, 2012

How to Send SMS With Kannel SMS and WAP gateway??

Continuing from My last Post.
Now We have our own SMS gateway up and working.But the million dollar question is how to send sms 
now from it?
So you can use following links on your browser or php codes to send SMS:

Just put your own username and password and you are good to go.

Now we can also build own PHP/MYSQL applications to send sms.
How We are going to do it ??
  1. User send his/her name by sms
  2. The message is forwarded to our application by the SMS box
  3. Our application store the sender name and telephone number in the database and then reply back to the user
Setting up the SMS box to foward every received message to our application{we had already done this in my last post here}

group = sms-service
keyword = default
get-url = "http://localhost/kannel/receivesms.php?sender=%p&text=%b"
accept-x-kannel-headers = true
max-messages = 3
concatenation = true
catch-all = true

We must make the get-url point to our script and passed the variables as querystring
%p – is the variable for the sender number
%b – represent the text message received
you can take a look at other available variables here
A Simple PHP Script:
function smsinsert($sender,$text)
 $con = 'mysql:dbname='.DBNAME.';host='.DBHOST;
 try {
      $cmd = new PDO($con,DBUSERNAME,DBPASSWORD);
   $stmt = $cmd->prepare("INSERT INTO kannel_tuto (number,message) VALUES (:sender,:message)");
   $cmd = null;
     echo "Hello ".$text.". Thank you for your registration.";
     echo "Sorry an error has occured";
  catch (PDOException $e) {
      echo 'Connection failed: ' . $e->getMessage();

The script is very simple.
1:Create your own database with phpmyadmin or mysql. 
2:We define a function smsinsert which will save the person name and phone number in our database.
3:The query string values are passed to the function
4:The function reply back by a success or failure message
5:The message is automatically send  to the sender.

No comments:

Post a Comment