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.
In reply to LWP form post example not working by perlchild
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |