perlchild has asked for the wisdom of the Perl Monks concerning the following question:
The following code, straight from the perldoc lwpcook documentation, is not working for me.
The site url and login info I cannot give out, but I can say that the site uses php and sessions to authenticate the username and password passed in by the form. It then redirects to the protected page if login successful or back to login page if not.
The problem when running the code is it should print the content of the protected page, instead, it prints out the content of the login page like the authentication has failed. However, there are no error messages in the response but it does send back 200 OK, which is strange since the protected page was not accessed.
Here is the code:
#!c:\perl\bin\perl -w use HTTP::Request::Common qw(POST); use LWP::UserAgent; $ua = LWP::UserAgent->new; push @{$ua->requests_redirectable}, 'POST'; my $req = POST 'http://www.(mypath)/login.php', [ username => 'masked', password => 'masked' ]; print $ua->request($req)->as_string; exit;
I have received really good help in the past here at perlmonks and I'm sure someone here can stear me in the right direction to solve this problem. Thanks in advance.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: LWP form post example not working
by afresh1 (Hermit) on Oct 10, 2008 at 22:00 UTC | |
by perlchild (Acolyte) on Oct 14, 2008 at 14:47 UTC | |
by afresh1 (Hermit) on Oct 14, 2008 at 21:29 UTC | |
by perlchild (Acolyte) on Oct 16, 2008 at 19:04 UTC | |
|
Re: LWP form post example not working
by clwolfe (Scribe) on Oct 11, 2008 at 04:25 UTC | |
by perlchild (Acolyte) on Oct 14, 2008 at 14:46 UTC | |
|
Re: LWP form post example not working
by Gangabass (Vicar) on Oct 11, 2008 at 08:37 UTC | |
by perlchild (Acolyte) on Oct 14, 2008 at 14:50 UTC |