473,382 Members | 1,180 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Sending an SMS using Perl and WWW::Mechanize

Hi,
I have a very small simple program below which does the following:
1) post a username & password to a website - THIS WORKS
2) follow a link - THIS WORKS
3) update values of 2 fields and post the form - ERROR!

This works fine using firefox even with javascript turned off.
But when using Perl (v5.8.8 on FC5) I get a page back stating an error has occured:
"We're sorry, an error has occurred. Please review the error below
There has been a server error, please try again later (ME-WT-04)."
Any help would be great.

###############################################
CODE
###############################################

use strict;
use WWW::Mechanize;
use HTTP::Cookies;
use LWP:: Debug qw(+); # remove the space between :: and Debug

# params
my $url = "http://www.vodafone.ie/";
my $username = "XXXXXXXXXX";
my $password = "XXXX";
my $number = "0857431234";
my $message = "HELLO THERE FROM MECH";

# setup
my $mech = WWW::Mechanize->new();
$mech->cookie_jar(HTTP::Cookies->new());
$mech->agent_alias( 'Windows IE 6' );

# post login
$mech->get($url);
$mech->form_name('loginform');
$mech->field('username' => $username);
$mech->field('password' => $password);
$mech->click();

# follow 1st link with "webtext" in it
$mech->follow_link( url_regex => qr/webtext/i );

# post message and number
$mech->form_name('WebText');
$mech->field('message' => $message);
$mech->field('recipients[0]' => $number);
$mech->click();

###############################################
LWP Debug qw(+) OUTPUT
###############################################

LWP::UserAgent::new: ()
LWP::UserAgent::request: ()
HTTP::Cookies::add_cookie_header: Checking www.vodafone.ie for cookies
HTTP::Cookies::add_cookie_header: Checking .vodafone.ie for cookies
HTTP::Cookies::add_cookie_header: Checking vodafone.ie for cookies
HTTP::Cookies::add_cookie_header: Checking .ie for cookies
LWP::UserAgent::send_request: GET http://www.vodafone.ie/
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::Protocol::collect: read 12 bytes ....(rest of reads cut out)

LWP::UserAgent::request: Simple response: OK
LWP::UserAgent::request: ()
HTTP::Cookies::add_cookie_header: Checking www.vodafone.ie for cookies
HTTP::Cookies::add_cookie_header: Checking .vodafone.ie for cookies
HTTP::Cookies::add_cookie_header: Checking vodafone.ie for cookies
HTTP::Cookies::add_cookie_header: Checking .ie for cookies
LWP::UserAgent::send_request: POST https://www.vodafone.ie/myv/services/login/Login.shtml
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
HTTP::Cookies::extract_cookies: Set cookie JSESSIONID => B56374FB9F26997837ECFC18F3029503
HTTP::Cookies::extract_cookies: Set cookie SITESELECTION => PERSONAL
LWP::UserAgent::request: Simple response: Found
LWP::UserAgent::request: ()
HTTP::Cookies::add_cookie_header: Checking www.vodafone.ie for cookies
HTTP::Cookies::add_cookie_header: - checking cookie path=/
HTTP::Cookies::add_cookie_header: - checking cookie SITESELECTION=PERSONAL
HTTP::Cookies::add_cookie_header: it's a match
HTTP::Cookies::add_cookie_header: - checking cookie JSESSIONID=B56374FB9F26997837ECFC18F3029503
HTTP::Cookies::add_cookie_header: it's a match
HTTP::Cookies::add_cookie_header: Checking .vodafone.ie for cookies
HTTP::Cookies::add_cookie_header: Checking vodafone.ie for cookies
HTTP::Cookies::add_cookie_header: Checking .ie for cookies
LWP::UserAgent::send_request: GET https://www.vodafone.ie/myv/index.jsp
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::Protocol::collect: read 1448 bytes ....(rest of reads cut out)
LWP::UserAgent::request: Simple response: OK
LWP::UserAgent::request: ()
HTTP::Cookies::add_cookie_header: Checking www.vodafone.ie for cookies
HTTP::Cookies::add_cookie_header: - checking cookie path=/
HTTP::Cookies::add_cookie_header: - checking cookie SITESELECTION=PERSONAL
HTTP::Cookies::add_cookie_header: it's a match
HTTP::Cookies::add_cookie_header: - checking cookie JSESSIONID=B56374FB9F26997837ECFC18F3029503
HTTP::Cookies::add_cookie_header: it's a match
HTTP::Cookies::add_cookie_header: Checking .vodafone.ie for cookies
HTTP::Cookies::add_cookie_header: Checking vodafone.ie for cookies
HTTP::Cookies::add_cookie_header: Checking .ie for cookies
LWP::UserAgent::send_request: GET https://www.vodafone.ie/myv/messaging/webtext/index.jsp?ts=1169527959878
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::Protocol::collect: read 1448 bytes ....(rest of reads cut out)
LWP::UserAgent::request: Simple response: OK
LWP::UserAgent::request: ()
HTTP::Cookies::add_cookie_header: Checking www.vodafone.ie for cookies
HTTP::Cookies::add_cookie_header: - checking cookie path=/
HTTP::Cookies::add_cookie_header: - checking cookie SITESELECTION=PERSONAL
HTTP::Cookies::add_cookie_header: it's a match
HTTP::Cookies::add_cookie_header: - checking cookie JSESSIONID=B56374FB9F26997837ECFC18F3029503
HTTP::Cookies::add_cookie_header: it's a match
HTTP::Cookies::add_cookie_header: Checking .vodafone.ie for cookies
HTTP::Cookies::add_cookie_header: Checking vodafone.ie for cookies
HTTP::Cookies::add_cookie_header: Checking .ie for cookies
LWP::UserAgent::send_request: POST https://www.vodafone.ie/myv/messaging/webtext/Process.shtml
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::UserAgent::request: Simple response: Found
LWP::UserAgent::request: ()
HTTP::Cookies::add_cookie_header: Checking www.vodafone.ie for cookies
HTTP::Cookies::add_cookie_header: - checking cookie path=/
HTTP::Cookies::add_cookie_header: - checking cookie SITESELECTION=PERSONAL
HTTP::Cookies::add_cookie_header: it's a match
HTTP::Cookies::add_cookie_header: - checking cookie JSESSIONID=B56374FB9F26997837ECFC18F3029503
HTTP::Cookies::add_cookie_header: it's a match
HTTP::Cookies::add_cookie_header: Checking .vodafone.ie for cookies
HTTP::Cookies::add_cookie_header: Checking vodafone.ie for cookies
HTTP::Cookies::add_cookie_header: Checking .ie for cookies
LWP::UserAgent::send_request: GET http://www.vodafone.ie/myv/messaging/webtext/Error.shtml
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::Protocol::collect: read 1448 bytes ....(rest of reads cut out)
LWP::UserAgent::request: Simple response: OK
Jan 23 '07 #1
2 8750
Unreal - I just found a module to do exactly what i need: WWW::SMS::IE::vodasms
Jan 23 '07 #2
Unreal - I just found a module to do exactly what i need: WWW::SMS::IE::vodasms
Hi BarryBevel. I'm trying to do the same thing in C#, but don't know how to approach it. Do I just have to connect to the site and send a small XML posting, or how fo you go about doing it. I've seen code in PERL, but don't know much about that.

Any help would be much appreciated,

Tom.
Mar 14 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: zoewu | last post by:
Would anyone help me with this little script that I tried to get some contents from Yahoo Personals by using Perl Mechanize. It doesn't return any results, although I've feed all kinds of browser...
1
by: coder57 | last post by:
Basically I have a local html file, called file1.html it has a series of links (with a particular domain name) in addition to the html code, I am trying to follow each of these links (based on the...
2
by: jenny04 | last post by:
I have a program which uses www::mechanize. But im having trouble installing it. Can anyone explain it to me or send me a website that has it on it. Any help will be appricated.
1
by: Edward Drake | last post by:
I'm trying to interact with a web page that uses JavaScript to add fields to a form if certain things are selected in the first field. I've tried doing something like this... ...
1
numberwhun
by: numberwhun | last post by:
I am having an issue with understanding something in the WWW::Mechanize module. I have a website which I want to download a whole plethora of pdf files from. It is a site that I have paid to access...
2
by: Silgd1 | last post by:
Hi all.... I'm using pyscripter 1.7.2, on a Win XP Prof 2002 - service pack 2 machine to script a website. I have no problem logging into the site, loading and an xml file, and retrieving the...
6
by: sureshbup | last post by:
Hi, i am new to perl... i tried this module mechanize. this is the script #!/usr/bin/perl # Include the WWW::Mechanize module use WWW::Mechanize;
0
by: trihaitran | last post by:
I am trying to write a web scraper and am having trouble accessing pages that require authentication. I am attempting to utilise the mechanize library, but am having difficulties. The site I am...
1
by: tedpottel | last post by:
Hi, I can read the home page using the mechanize lib. Is there a way to load in web pages using filename.html instad of servername/ filename.html. Lots of time the links just have the file...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.