NetSDS::Kannel(3pm) | User Contributed Perl Documentation | NetSDS::Kannel(3pm) |
NetSDS::Kannel - Kannel SMS gateway API
#!/usr/bin/env perl use 5.8.0; use warnings; use strict; use NetSDS::Kannel; my $kannel = NetSDS::Kannel->new( sendsms_url => 'http://localhost:1234/sendsms', sendsms_user => 'sender', sendsms_passwd => 'secret', default_smsc => 'esme-megafon', ); $res = $kannel->send( from => '1234', to => '380672222111', text => 'Hallo there!', smsc => 'emse-mts', priority => 3, ); 1;
"NetSDS::Kannel" module provides API to Kannel SMS gateway.
To decrease innecessary problems we use a lot of predefined parameters while sending and receiving messages via Kannel HTTP API. It's not so flexible as direct HTTP processing but less expensive in development time ;-)
This modules uses LWP to send messages and CGI.pm to process messages from Kannel.
Admin API parameters:
* admin_url - Kannel admin API URL
* admin_passwd - password to admin API
Sending SMS API parameters:
* sendsms_url - URL of Kannel sendsms HTTP API
* sendsms_user - user name for sending SMS
* sendsms_passwd - password for sending SMS
* dlr_url - base URL for DLR retrieving
* default_smsc - default SMSC identifier for sending SMS
* default_timeout - default sending TCP timeout
Parameters (mostly the same as in Kannel sendsms API):
* from - source address (overrides message)
* to - destination address (overrides message)
* text - message text (byte string)
* udh - user data header (byte string)
* charset - charset of text
* coding - 0 for GSM 03.38, 1 for binary, 2 for UCS2
* smsc - target SMSC (overrides default one)
* mclass - message class if necessary (0 for flash sms)
* validity - TTL for MO SM in minutes
* deferred - timeout for delayed delivery
Example:
use NetSDS::Kannel; use NetSDS::Util::Misc; my $kannel = NetSDS::Kannel->new(...); $kannel->send_sms( from => '1234', to => '380672206770', text => 'Wake up!!!', smsc => 'nokia_modem', msgid => make_uuid, );
Message type (MO or DLR) recognized by "type" CGI parameter that may be "mo" or "dlr".
my $cgi = CGI::Fast->new(); my %ret = $kannel->receive($cgi);
Imported MO message parameters returned as hash with the following keys:
* smsc - Kannel's SMSC Id
* smsid - SMSC message ID
* from - subscriber's MSISDN
* to - service address (short code)
* time - SMS receive time
* unixtime SMS receive time as UNIX timestamp
* text - MO SM text
* bin - MO SM as binary string
* udh - SMS UDH (User Data Headers)
* coding - SMS encoding (0 - 7 bit GSM 03.38; 2 - UCS2-BE)
* charset - charset of MO SM text while receiving from Kannel
* binfo - SMPP "service_type" parameter for billing puroses
"receive_dlr" method returns hash with the following keys:
* smsc - kannel SMSC id
* msgid - original MT SM message id for DLR identification
* smsid - SMSC message ID
* from - subscriber's MSISDN (phone number)
* to - service address (short code)
* time - delivery time
* unixtime - delivery time as UNIX timestamp
* dlr - DLR state
* dlrmsg - DLR message from SMSC
Example:
my $cgi = CGI->new(); my %dlr = $kannel->receive_dlr($cgi); print "DLR received for MSISDN: " . $dlr{from};
Paramters: hash (dlr_url, msgid)
Returns: URI escaped DLR URL
Format of "meta-data" parameter value:
?smpp?tag1=value1&tag2=value2&...tagN=valueN
Paramters: hash of TLV pairs
Returns: URI escaped string
Example:
my $meta = $self->make_meta( charging_id => '0', );
This will return: %3Fsmpp%3Fcharging_id%3D0
See Nibelite kannel API
1. Add PPG support.
2. Add OTA support.
Michael Bochkaryov <misha@rattler.kiev.ua>
Copyright (C) 2008-2009 Net Style Ltd.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2021-12-26 | perl v5.32.1 |