munk.me.uk forum
May 21, 2012, 05:01:12 am *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: SMF - Just Installed!
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Icqsms v0.2  (Read 2224 times)
munks g0at


Karma: +0/-0
Offline Offline

Posts: 8



View Profile Email
« on: April 30, 2003, 11:50:25 am »

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.

Code:
#!/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

Code:
$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.
 
Logged
munk
Administrator
Sr. Member
*****

Karma: +2/-0
Offline Offline

Posts: 368


View Profile WWW
« Reply #1 on: May 01, 2003, 02:55:06 pm »

Nice one dude.  I'm looking for a method to send sms msgs to Eugene actually - still having a hard time finding a site that'll let me send free SMS to aus mobile numbers Sad

I suppose your code could be used to do that perhaps?

I've not used ICQ for ages now - I'm presuming you don't need to have the ICQ agent running on your machine and it's all done via HTTP?
Logged

~ Jez
munks g0at


Karma: +0/-0
Offline Offline

Posts: 8



View Profile Email
« Reply #2 on: May 02, 2003, 07:48:17 am »

Yeah just give it an account and it will work. Works to Aus mobile phone numbers if they are with the major 3 providers: Vodafone, Telstra (me with them), and Optus. Eugene is with Orange but I think he has an Optus phone too.
« Last Edit: May 02, 2003, 07:52:41 am by munks g0at » Logged
munk
Administrator
Sr. Member
*****

Karma: +2/-0
Offline Offline

Posts: 368


View Profile WWW
« Reply #3 on: May 04, 2003, 03:07:21 am »

Gak only just seen your reply - something's gone awry with my mailer ;/

I'll try and get al to set it up - sounds like he knows about it already.  Try being the operative word - he gets enough emails from me already as it is let alone actively contributing to getting spammed via SMS as well Smiley
Logged

~ Jez
munks g0at


Karma: +0/-0
Offline Offline

Posts: 8



View Profile Email
« Reply #4 on: May 05, 2003, 02:22:35 am »

Ah, thats okay. I havent checked for a reply for a while Cheesy
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.13 | SMF © 2006-2011, Simple Machines LLC Valid XHTML 1.0! Valid CSS!