IntUnsigned

Perl SMS Sender via Skype API – kSMS

by kry0 on Jul.19, 2010, under Perl Dev

If you have Skype Out credit and want to send an SMS via the command line I developed this basic Skype API interface code. It means you can send an SMS triggered by any event on the system whereby you invoke the kSMS code as required and pass parameters for the target phone number/message.  I developed this as I wanted a way to send myself an SMS message after performing some web scraping (in this case i wrote code to get my bank balance from the online banking website and then send it to me with this SMS code). To run the code you need Net::DBus::Skype perl module installed and Skype to be running in DBus mode (see the code for how to do that). So with this you have the freedom to send SMS’s as required for any purpose under full control of other code. Read on for the code.

#!/usr/bin/perl
#interface with skype/api via dbus
#to auto send an sms.. enabling sms automation
#kry0/bpr/jan/2010

#make sure and start skype with
#skype –use-system-dbus
#or u get error ‘no skype api available’
#ALSO MAKE SURE U ARE RUNNING THIS PROG UNDER SAME USER THAT SKYPE WAS
#STARTED UNDER

#glob destmin/msg
my $destmin=$ARGV[0];
my $destmsg=$ARGV[1];

unless($destmin && $destmsg) { print qq{Usage:\nperl kSMS.pl DESTMIN ‘DESTMSG’\neg. perl kSMS.pl +447588445663 ‘ksms test!’\nkry0/bPR/jan/2010\n\n};exit; };

use Net::DBus::Skype;

my $s = Net::DBus::Skype->new;
my $s = Net::DBus::Skype->new({ debug => 1 });

my $res=sendRaw($s,”CREATE SMS OUTGOING $destmin”);
$res=~/SMS\s(\d*?)\s/;    #grab sms id from response string
my $smsid=$1;
$res=sendRaw($s,”SET SMS $smsid BODY $destmsg”);
$res=sendRaw($s,”ALTER SMS $smsid SEND”);
$res=sendRaw($s,”DELETE SMS $smsid”);
print qq{kSMS SMS Sent to MIN.. l8r!\n\n};
#skype raw send and return response
sub sendRaw {
my $sapiobj=shift;
my $msg=shift;
my $res=$sapiobj->raw_skype($msg);
$res;

};


Comments are closed.

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!