471,854 Members | 1,537 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,854 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 8493
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

Post your reply

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

Similar topics

reply views Thread by zoewu | last post: by
2 posts views Thread by jenny04 | last post: by
6 posts views Thread by sureshbup | last post: by
1 post views Thread by tedpottel | last post: by
reply views Thread by YellowAndGreen | last post: by

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.