Question

I am trying to automate sms sending through Way2sms in Perl LWP. I am able to login successfully. Then I click the Send SMS link in the browser to go the sms-sending page. From there, based upon the page url and the url of the iframe within which the sms fields are located, I try to construct the absolute URL of the page to which the form should be posted, and post it with the correct parameters (you can see it all in the image). However, the sms isn't being sent. Can anybody tell me what am I doing wrong here? (There is a similar module in CPAN which accomplishes this through Mechanize, I am trying a different approach)

use LWP::UserAgent;
use HTTP::Cookies;
my $cookie_jar = HTTP::Cookies->new(
file => "cookies.txt",
autosave => 1,
);
my $ua = LWP::UserAgent->new(
    agent =>
      'Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20100101 Firefox/14.0.1',
    cookie_jar => $cookie_jar,
);
my $response = $ua->post(
    'http://site2.way2sms.com/contentt/bar/Login1.action',
    {
        username => $mob,
        password => $pass,
    }
);

if ( $response->is_redirect ) {
    $response = $ua->get( $response->header('Location') );
    print 5 if $response->decoded_content =~ /Kaustav Mukherjee/i; #prints it, showing that the login is successful
}
my $smsresp = $ua->post("http://site5.way2sms.com/jsp/quicksms.action",[MobNo=>$mob,textArea=>'Hello World']);
if ( $smsresp->is_redirect ) {
   $smsresp = $ua->post($smsresp->header('Location'),[MobNo=>$mob,textArea=>'Hello World']);
   }

enter image description here

No correct solution

OTHER TIPS

Here is an indirect answer that may help you out:

  1. If you have to use this website, try using something like CasperJS. There may be some JavaScript magic that needs to happen.
  2. Maybe you could use something like Google Voice or some other smarter service to automate send text messages. Looks like someone on CPAN already has a sweet Google::Voice module for this.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top