Hey munk,
I have been looking for some way to send SMS messages for free. I also wanted the service to be reliable. I was looking around and couldn't really find anything that suited. Then I remembered ICQ offer SMS services and saw they had an area on their site where you are able to send SMS messages. So I wrote this Perl bot (with help from AlCapone B) ) which logs in to ICQ and send out an SMS.
I will be using this script on my home box with a shell script to send me SMS alerts for when I get emails from certain people or that have certain words in subject.
#!/usr/bin/perl -w
use strict;
use Getopt::Long;
use LWP::UserAgent;
use HTTP::Cookies;
use URI::Escape;
if(!@ARGV or $ARGV[0] eq '-h') {
print <<help;
ICQ SMS v0.2
This perl script will send an SMS via ICQ's SMS Center
Synopsis: icqsms.pl -n +61411123123 -m 'Your SMS'
Available options:
\t-n\t mobile phone number to send SMS to, must be in International format (string)
\t-m\t message to send
help
exit;
}
my $message=0;
my $mobilenumber=0;
my $loginlocation=0;
my $password=0;
my $icq=0;
my $login=0;
my $smslocation=0;
print 'Loading information from config file',$/;
open(FILE, '<.icqsms.conf') || die "Failed to load config file\n";
my @lines = <FILE>;
close FILE;
eval("@lines");
die "Failed to load config file\n" if ($@);
GetOptions('m=s'=>\$message,'n=s'=>\$mobilenumber) or exit;
print 'Preparing ICQ Login Information',$/;
$login="lang=lang=eng&karma_success_url=http%3A%2F%2Fweb.icq.com%2Fsms%2Finbox%2F%3F&karma_fail_url=%2Flogin%2Flogin_page%3Fkarma_product_css%3Dicq2go%26karma_success_url%3Dhttp%253A%252F%252Fweb%252Eicq%252Ecom%252Fsms%252Finbox%252F%253F%26karma_forget%3D%26karma_service%3D&karma_service=&karma_user_login=".$icq."&karma_user_passwd=".$password;
print 'Preparing SMS form data',$/;
my %nfo=(
'country'=>'',
'prefix'=>'',
'carrier'=>'',
'tophone'=>uri_escape($mobilenumber),
'uSend'=>'1',
'msg'=>$message
);
my $info='';
foreach my $key (keys %nfo){ $info.=$key.'='.$nfo{$key}.'&';}
$info=substr($info,0,length($info)-1);
my $ua = new LWP::UserAgent;
$ua->agent('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.0) Gecko/20020530');
$ua->cookie_jar(HTTP::Cookies->new(file=>'lwp.cookies',autosave=>1));
my $req = HTTP::Request->new(POST => $loginlocation);
$req->protocol('HTTP/1.1');
$req->content_type('application/x-www-form-urlencoded');
$req->content_length(length($login));
$req->content($login);
my $res = $ua->request($req);
print 'Sending request to login',$/;
if($res->is_error()) {
print "There was an error connecing to $loginlocation, please try again";
exit;
}
$req=HTTP::Request->new(POST=>$smslocation);
$req->content_type('application/x-www-form-urlencoded');
$req->content($info);
print 'Sending SMS details to ICQ',$/;
$res=$ua->request($req);
if($res->is_error()){
print 'There was an error sending SMS',$/;
exit;
}
print 'SMS has been sent',$/;
The config file format is as follows
$icq='1234567';
$password='password';
$loginlocation='http://web.icq.com/newlogin/1,,,00.html';
$smslocation='http://web.icq.com/sms/send_msg_tx/1,,,00.html';
Just use an existing ICQ account you have or create a new one (thats what i did). It loads the config file from the users home directory so script can be used on server and have multiple users setup for it.