mnem0 has asked for the wisdom of the Perl Monks concerning the following question:
i also tried WWW::Mechanize. Every time i launch my script, the host login page answers "bad login or password" (i checked the l/p i sent, they do work when sent via Firefox.) i captured the http headers of a succesful login connection made via firefox to understand:#!"C:\perl\bin\perl.exe" use strict; use warnings; use HTTP::Cookies; use LWP::UserAgent; my $ua = LWP::UserAgent->new; $ua->cookie_jar(HTTP::Cookies->new(file => "cookie2.txt",autosave => 1 +,)); my $url_base = "http://www.host.com/login.php"; my $response = $ua->get($url_base); my $contenu = $response->content; $content =~ s/\n//g;#extracting session id my @sids = split(/sid=/,$content); my $id; shift(@sids); foreach $id(@sids){ $id =~ s!"(.*)!!; } my $res = $ua->post ($url_base.'?sid='.$sids[0],[username => 'myUserNa +me', password=>'myPassword',login=>'Connexion']);
i seem to post the good params at the good place. i don't see where i'm wrong :/http://www.host.com/login.php?sid=bfa659dd671fec73949f2f711a6c72d6 POST /login.php?sid=bfa659dd671fec73949f2f711a6c72d6 HTTP/1.1 Host: www.host.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.1.13) +Gecko/20080311 Firefox/2.0.0.13 Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9 +,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Referer: http://www.host.com/index.php Cookie: eb033c292a139b620ecb662dda3f1a1b=-; mosvisitor=1; phpbb2mysql_ +data=a%3A2%3A%7Bs%3A11%3A%22autologinid%22%3Bs%3A0%3A%22%22%3Bs%3A6%3 +A%22userid%22%3Bi%3A-1%3B%7D; phpbb2mysql_sid=bfa659dd671fec73949f2f7 +11a6c72d6 Content-Type: application/x-www-form-urlencoded Content-Length: 49 username=myUserName&password=myPassword&login=Connexion HTTP/1.x 302 OK Date: Thu, 03 Apr 2008 07:16:46 GMT Server: Apache/1.3.34 Ben-SSL/1.55 X-Powered-By: PHP/4.4.8 Set-Cookie: phpbb2mysql_data=a%3A2%3A%7Bs%3A11%3A%22autologinid%22%3Bs +%3A0%3A%22%22%3Bs%3A6%3A%22userid%22%3Bs%3A3%3A%22190%22%3B%7D; expir +es=Fri, 03 Apr 2009 07:16:47 GMT; path=/ Set-Cookie: phpbb2mysql_sid=bfa659dd671fec73949f2f711a6c72d6; path=/ Location: http://www.host.com/index.php?sid=bfa659dd671fec73949f2f711a +6c72d6 Keep-Alive: timeout=2, max=200 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/html
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: LWP::UserAgent can't login to phpbb forum
by Corion (Patriarch) on Apr 03, 2008 at 08:29 UTC | |
by jettero (Monsignor) on Apr 03, 2008 at 11:03 UTC | |
by mnem0 (Initiate) on Apr 03, 2008 at 15:31 UTC | |
by Corion (Patriarch) on Apr 03, 2008 at 15:52 UTC | |
|
Re: LWP::UserAgent can't login to phpbb forum
by UnderMine (Friar) on Apr 03, 2008 at 09:43 UTC | |
|
Re: LWP::UserAgent can't login to phpbb forum
by CountZero (Bishop) on Apr 03, 2008 at 21:41 UTC |