NetSDS::Kannel(3pm)
π NetSDS::Kannel π
okay bestie, so this is NetSDS::Kannel(3pm) β a User Contributed Perl Documentation page, and it's literally the Kannel SMS gateway API. yes. SMS. in perl. we love to see it π«Ά
β¨ NAME β¨
NetSDS::Kannel β Kannel SMS gateway API
πΈ SYNOPSIS πΈ
like, here's the whole vibe in one go:
#!/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;
not me noticing emse-mts in there π it's in the original, so it stays in the original, i don't make the rules, i just keep them exactly as they are, no cap.
π¦ DESCRIPTION π¦
so NetSDS::Kannel is the module that gives you an API to the Kannel SMS gateway. that's the whole thing. it's giving "i speak fluent SMS so you don't have to" π
here's the tea: to keep you from drowning in unnecessary problems, this module comes with a lot of predefined parameters baked in for sending and receiving messages through the Kannel HTTP API. it's not as flexible as talking straight to HTTP yourself, but it's way less expensive in development time ;-) β pick your fighter.
and for the technical girlies: this module uses LWP to send messages, and CGI.pm to process messages coming back from Kannel. iconic combo honestly.
π CLASS API π
new(%params) β class constructor
the constructor makes your Kannel API handler and sets its configuration up. most of these params can be overridden later when you call object methods, so don't stress too hard.
Admin API parameters:
admin_urlβ Kannel admin API URLadmin_passwdβ password to admin API
Sending SMS API parameters:
sendsms_urlβ URL of Kannel sendsms HTTP APIsendsms_userβ user name for sending SMSsendsms_passwdβ password for sending SMSdlr_urlβ base URL for DLR retrievingdefault_smscβ default SMSC identifier for sending SMSdefault_timeoutβ default sending TCP timeout
π OBJECT METHODS π
send(%parameters) β send MT SM message to Kannel
this is the one. this method lets you send an SMS message through the Kannel SMS gateway. main character energy fr fr β¨
Parameters (mostly the same as in the Kannel sendsms API, so iykyk):
fromβ source address (overrides message)toβ destination address (overrides message)textβ message text (byte string)udhβ user data header (byte string)charsetβ charset of textcodingβ0for GSM 03.38,1for binary,2for UCS2smscβ target SMSC (overrides default one)mclassβ message class if necessary (0for flash sms)validityβ TTL for MO SM in minutesdeferredβ 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,
);
receive($cgi) β receive MO or DLR from CGI object
this method imports a message structure straight from a CGI request. lowkey it's just a wrapper around receive_mo() and receive_dlr() β it's the girl who introduces you to her two friends.
message type (MO or DLR) is recognized by the type CGI parameter, which may be mo or dlr.
my $cgi = CGI::Fast->new();
my %ret = $kannel->receive($cgi);
receive_mo($cgi) β import MO message from CGI object
this method imports a message structure from a CGI request.
the imported MO message parameters come back as a hash with these keys:
smscβ Kannel's SMSC Idsmsidβ SMSC message IDfromβ subscriber's MSISDNtoβ service address (short code)timeβ SMS receive timeunixtimeβ SMS receive time as UNIX timestamptextβ MO SM textbinβ MO SM as binary stringudhβ 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 Kannelbinfoβ SMPPservice_typeparameter for billing purposes
receive_dlr($cgi) β import message from CGI object
this method imports a message structure from a CGI request.
receive_dlr returns a hash with these keys:
smscβ kannel SMSC idmsgidβ original MT SM message id for DLR identificationsmsidβ SMSC message IDfromβ subscriber's MSISDN (phone number)toβ service address (short code)timeβ delivery timeunixtimeβ delivery time as UNIX timestampdlrβ DLR statedlrmsgβ DLR message from SMSC
Example:
my $cgi = CGI->new();
my %dlr = $kannel->receive_dlr($cgi);
print "DLR received for MSISDN: " . $dlr{from};
make_dlr_url(%params) β prepare DLR URL
this method creates a URI escaped string with a URL template for DLR notification.
Parameters: hash (dlr_url, msgid)
Returns: URI escaped DLR URL
make_meta(%params) β prepare SMPP optional TLV
this method creates a URI escaped string with optional SMPP tag-length-value (TLV) parameters, so you can send them in the meta-data CGI parameter of Kannel's sendsms HTTP API. it's giving "packaging my little extras cute" π
format of the meta-data parameter value:
?smpp?tag1=value1&tag2=value2&...tagN=valueN
Parameters: hash of TLV pairs
Returns: URI escaped string
Example:
my $meta = $self->make_meta(
charging_id => '0',
);
this will return: %3Fsmpp%3Fcharging_id%3D0
the rest of the method roster π―
status()β retrieve Kannel statusstore_status()β retrieve message queue status
not implemented yet. bestie it's a promise, not a feature π
shutdown()β bring down Kannelsuspend()β switch Kannel to 'suspended' stateisolate()β switch Kannel to 'isolated' stateresume()β resume Kannel to 'online' staterestart()β whole bearerbox restartflush_dlr()β flush queued DLR if Kannel in 'suspended' statereload_lists()β reload black/white listslog_level($level)β change Kannel log-levelstart_smsc($smsc)β switch on SMSC connectionstop_smsc($smsc)β switch off SMSC connectionadd_smsc($smsc)β add new SMSC connectionremove_smsc($smsc)β remove SMSC connection
π EXAMPLES π
see Nibelite kannel API
β SEE ALSO β
NetSDS::Class::Abstractβ base NetSDS class- <http://www.kannel.org/download/1.4.3/userguide-1.4.3/userguide.html> β Kannel User Guide
π§ TODO π§
- add PPG support.
- add OTA support.
like, someday. we manifest πΈ
π AUTHOR π
Michael Bochkaryov <misha@rattler.kiev.ua>
π LICENSE π
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
π yes, "WITHOUT ANY WARRANTY" is in all caps in the original too, and honestly? it deserves the drama. that's not a vibe, that's a legally binding mood. respect it.
and that's the whole page bestie!! π this one's from perl v5.32.1, dated 2021-12-26, and it's NetSDS::Kannel(3pm) β go text somebody, responsibly πβ¨π¦
π¦ where this page comes from
- debian bookworm: libnetsds-kannel-perl 1.300-7 Β· GPL-2.0-or-later
- debian trixie: libnetsds-kannel-perl 1.300-7 Β· GPL-2.0-or-later
- ubuntu jammy: libnetsds-kannel-perl 1.300-7 Β· GPL-2.0-or-later
- ubuntu noble: libnetsds-kannel-perl 1.300-7 Β· GPL-2.0-or-later
- ubuntu resolute: libnetsds-kannel-perl 1.300-7 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms