Professional Documents
Culture Documents
Sms Server
Sms Server
o Install
o Aptitude search sms/smstools o Sudo apt-get install smstools
SMS Server Tools Config files start stop config file error logfile sms queues Apache webserver
start /etc/init.d/apache2 start stop /etc/init.d/apache2 stop config file /usr/apache2/conf/httpd.conf error logfile /usr/apache2/logs/error.log web pages /usr/apache2/htdocs The location of these files is different on some linux distributions. MySQL database
Cron Jobs
Programs the run repeatedly at specified times Every day, hour, minute Windows nnCron lite c:\programme\cron\cron.tab Part of *nix systems
*/10****cp/tmp/logfile.old /tmp/logfile.new minute (0-59) hour (0-23) day (1-31) month (1-12) weekday (0=sunday, 1=monday, ...)
Kannel
Communicates to the phone via wap stack and translates request it receives to http for content and service providers Compresses WML scripts into more compact format to save bandwidth and Abstract various smsc protocols and exposes http interface for content providers
Copyright 2011. World Wide Web Foundation. All rights reserved
SMS
Kannel
bearerbox
-
Accepts sms and wap messages and sends them to other boxes Handles wap messages
wapbox
-
smsbox
-
It is possible to have multiple sms and wap boxes on the same or different hosts
Kannel on Debian
Kannel Setup
# mkdir src # cd src # tar xfz ../downloads/gateway-1.4.1.tar.gz # cd gateway-1.4.1 # configure prefix=/usr/local/kannel # make # sudo make install password: **************
group = core admin-port = 13000 smsbox-port = 13001 admin-password = bar log-file = "/tmp/kannel.log" log-level = 0
- -
0 - 4. 0 => debug and development 4=>critical errors and problems Ex 0 for development and 1 for production
Smsc Group
Kannel allows many smsc conf - Fakesms service for development and testing - GSM - SMS service over Http group = smsc smsc = at modemtype = auto device=/dev/ttyUSB* - Serial port through which device is connected my-number = XXXXXXXXXX connect-allow-ip = 127.0.0.1 log-level = 0
Copyright 2011. World Wide Web Foundation. All rights reserved
log-level = 0
Configures how Kannel sends messages to applications Possible to setup to catch incoming messages based on various criteria Using HTTP Get to send message to an app all messages go to one script
- - - - -
group = sms-service keyword = keyword-regex = .* catch-all = yes Max-messages = 0 Tells kannel to never send reply directly from incoming message ans for :<empty reply for service provider> get-url = "http://localhost/sms?phone=%p&text=%a"
Kannel calls the url sepecified in sms-service group Further processing and use up to us and the specific application/service we intend to deliver
Done over Http function sendSmsMessage($in_phoneNumber, $in_msg)! {! $url = '/cgi-bin/sendsms?username=' . CONFIG_KANNEL_USER_NAME! . '&password=' . CONFIG_KANNEL_PASSWORD! . '&charset=UCS-2&coding=2'! . "&to={$in_phoneNumber}"! . '&text=' . urlencode(iconv('utf-8', 'ucs-2', $in_msg));! $results = file('http://'! . CONFIG_KANNEL_HOST . ':'! . CONFIG_KANNEL_PORT . $url);! }!
Kannel Hands on
courtesy: <http://www.dijexi.com/2010/05/setup-kannel-sms-gateway-on-ubuntu/#more-1320>
Enable SMSBOX
sudo vi /etc/default/kannel
- -
START_WAPBOX=1 START_SMSBOX=1
Add kannel user to dialout group to enable kannel user to use /dev/ttyUSB0 device that is necessary for GSM modems
sudo vi /etc/group
-
dialout:x:20:daniel,kannel
FrontlineSMS Keywords
Information pull
Keywords auto reply can be sent to provide the requested information We can also link keywords to forward message to a predifined group or individual
-
This allows for of FLSMS be programmed to perform some action based on an external (http) command Need to establish port to listen to Format
<?php include_once("config.php"); // database definition include_once("dbclass.php"); // sql Where Conditios $objDB = new DB(); // Query messages by campaign ID // if(isset($_POST['campaignid']) && $_POST['campaignid'] != "") { $Query = "select * from custom_fields where campaign = '".$_POST['campaignid']."' "; $objDB->setQuery($Query); $rs = $objDB->select(); ?> <?php if(count($rs)>0) { $counter = 0; foreach($rs as $data) { // You can change the format or the message here //------- Message Format ---------$message =rawurlencode($data['var1']." ".$data['var2']." ".$data['var3']." ".$data['var4']); //------- Message Format ---------$url = "http://localhost:8000/send/sms/".$data['phone']."/".$message."/";
// Using Curl $curl_handle=curl_init(); curl_setopt($curl_handle,CURLOPT_URL,$url); curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2); $output = curl_exec($curl_handle); curl_close($curl_handle); $content.= $url." - ".$output; // used for debug $content.="- ".$data['phone']."<br/>"; // used for debug ?>
String encodedPhoneNumber = URLEncoder.encode ("+2348069361226","UTF-8");! String encodedMessage = URLEncoder.encode("helo","UTF-8");! URL url=new URL("http://localhost: 8181/send/sms/"! + encodedPhoneNumber + "/"! + encodedMessage);!