Pages

Showing posts with label kannel sms. Show all posts
Showing posts with label kannel sms. Show all posts

Friday, March 4, 2011

How to receive and save SMS through Kannel

This is the relevant configuration part of the kannel.conf file;

group = sms-service
keyword = default
#keyword-regex = .*
catch-all = yes
max-messages = 0
get-url = "http://localhost:23456/sms.php?ORIGINATOR=%p&RECEIVER=%P&SMS=%a&SOURCE_PRV=%o"



At local host (same as where i run my kannel server) i have this code in the file sms.php;

$query = "insert into sms set sender='".$_GET["ORIGINATOR"]."', receiver='".$_GET["RECEIVER"]."', msg='".$_GET["SMS"]."', source_prv='".$_GET["SOURCE_PRV"]."'";
$result = mysql_query($query);
if(!$result) die(sql_error());

Make sure that you have defined your database connectivity parameters before this code. What kannel does is just he receive a SMS it calls the URL defined as the get-url in the .conf file. And passing the parameters in GET method. Now you are able to receive and save a SMS through kannel.