Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Unable to Send SMS

by Rahul Gupta (Sexton)
on Jun 11, 2013 at 11:53 UTC ( #1038240=perlquestion: print w/ replies, xml ) Need Help??
Rahul Gupta has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I wrote one script to send sms but i am getting some error.

the code is
#!/usr/bin/perl use WWW::Mechanize; use Compress::Zlib; my $mech = WWW::Mechanize->new(); my $username = ""; #fill in username here my $keyword = ""; #fill in password here my $mobile = $ARGV[0]; my $text = $ARGV[1]; $deb = 1; print length($text)."\n" if($deb); $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($deb); if($mech->response->header("Content-Encoding") eq "gzip") { $dest = Compress::Zlib::memGunzip($dest); $mech->update_html($dest); } $dest =~ s/<form name="loginForm"/<form action='..\/Login1.action' nam +e="loginForm"/ig; #< $dest =~ s/<form name="loginForm"/<form action='..\/auth.cl' name=" +loginForm"/ig; > # $dest =~ s/<form name="loginForm"/<form action='..\/Login1.action' n +ame="loginForm"/ig; $mech->update_html($dest); $mech->form_with_fields(("username","password")); $mech->field("username",$username); $mech->field("password",$keyword); print "Loggin...\n" if($deb); $mech->submit_form(); print "Rahul\n"; $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($deb); $mech->form_with_fields(("MobNo","textArea")); $mech->field("MobNo",$mobile); $mech->field("textArea",$text); $mech->submit_form(); if($mech->success()) { print "Done \n" if($deb); } else { print "Failed \n" if($deb); exit; } $dest = $mech->response->content; if($mech->response->header("Content-Encoding") eq "gzip") { $dest = Compress::Zlib::memGunzip($dest); #print $dest if($deb); } if($dest =~ m/successfully/sig) { print "Message sent successfully" if($deb); } exit;
Error what i am getting is:
5 Fetching... Loggin... Error POSTing http://wwwl.way2sms.com/Login1.action: Not Found at SMS. +pl line 48

please help me to resolve this issue.

thanks in advance

Comment on Unable to Send SMS
Select or Download Code
Re: Unable to Send SMS
by hdb (Prior) on Jun 11, 2013 at 12:07 UTC

    I cannot give you a full answer, but to me it looks that you manipulate the form's action:

    $dest =~ s/<form name="loginForm"/<form action='..\/Login1.action' nam +e="loginForm"/ig;

    which is later not recognized by the server:

    Error POSTing http://wwwl.way2sms.com/Login1.action: Not Found at SMS. +pl line 48

    Is such cases I would advise to study the webpages' source code again.

Re: Unable to Send SMS
by rpnoble419 (Pilgrim) on Jun 12, 2013 at 01:02 UTC

    I use the SMS::Send with the Twilio add-on. It costs me 1 cent per message, took me 9 minutes to get it up and running with 12 lines of code.

    #!C:/strawberry/perl/bin/perl.exe use strict; use warnings; use SMS::Send; # Create an object. There are three required values: my $sender = SMS::Send->new('Twilio', _accountsid => 'Acount SID here', _authtoken => 'Twilio Token here', _from => '+1 Twilio Phone number here' ); # Send a message to me my $sent; eval{ $sent = $sender->send_sms( text => 'text to send', to => '+12125551212' #sample phone number ); }; my $error = $@; # Did it send? if ( $@ ) { print "Unable to send Message ".$@; }

    This code is an example cut out of a larger script.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1038240]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2014-09-22 03:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (178 votes), past polls