Created
August 18, 2011 17:31
-
-
Save vikraman/1154588 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use warnings; | |
use strict; | |
use Data::Dumper; | |
use WWW::Mechanize; | |
use Compress::Zlib; | |
my $mech = WWW::Mechanize->new(); | |
my $username = "9038090380"; | |
my $password = "password"; | |
my $mobile = $ARGV[0]; | |
my $text = $ARGV[1]; | |
my $verbose = 1; | |
my $debug = 0; | |
print length($text)."\n" if($verbose); | |
$text = $text."\n\n\n\n\n" if(length($text) < 135); | |
$mech->get("http://wwwl.way2sms.com/content/index.html"); | |
unless($mech->success()) | |
{ | |
exit; | |
} | |
my $dest = $mech->response->content; | |
print "Fetching...\n" if($verbose); | |
if($mech->response->header("Content-Encoding") eq "gzip") | |
{ | |
$dest = Compress::Zlib::memGunzip($dest); | |
$mech->update_html($dest); | |
} | |
$dest =~ s/<form name="loginForm"/<form action='..\/auth.cl' name="loginForm"/ig; | |
$mech->update_html($dest); | |
$mech->form_with_fields(("username","password")); | |
$mech->field("username",$username); | |
$mech->field("password",$password); | |
print "Logging in...\n" if($verbose); | |
$mech->submit_form(); | |
$dest= $mech->response->content; | |
if($mech->response->header("Content-Encoding") eq "gzip") | |
{ | |
$dest = Compress::Zlib::memGunzip($dest); | |
$mech->update_html($dest); | |
} | |
$mech->get("http://wwwl.way2sms.com//jsp/InstantSMS.jsp?val=0"); | |
$dest= $mech->response->content; | |
if($mech->response->header("Content-Encoding") eq "gzip") | |
{ | |
$dest = Compress::Zlib::memGunzip($dest); | |
$mech->update_html($dest); | |
} | |
print "Sending ... \n" if($verbose); | |
$mech->form_with_fields(("MobNo","textArea")); | |
$mech->field("MobNo",$mobile); | |
$mech->field("textArea",$text); | |
$mech->submit_form(); | |
if($mech->success()) | |
{ | |
print "Done \n" if($verbose); | |
} | |
else | |
{ | |
print "Failed \n" if($verbose); | |
exit; | |
} | |
$dest = $mech->response->content; | |
if($mech->response->header("Content-Encoding") eq "gzip") | |
{ | |
$dest = Compress::Zlib::memGunzip($dest); | |
print $dest if($debug); | |
} | |
if($dest =~ m/successfully/sig) | |
{ | |
print "Message sent successfully" if($verbose); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment