DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Perl (http://www.daniweb.com/forums/forum112.html)
-   -   LWP for login to an web application (http://www.daniweb.com/forums/thread199078.html)

maxjackie Jun 22nd, 2009 3:37 pm
LWP for login to an web application
 
Hello friends ,

I have a problem like there is web application and i have to write
a script that should login to the application and then move other parts
of the application

 use HTTP::Request::Common qw(POST);
 use LWP::UserAgent;
 use Data::Dumper;

$ua = LWP::UserAgent->new(keep_alive=>1);

my $req = POST "http://servername.com:5002/index.php",
        ['user_name' => 'username',
          'user_password'=>"password",
          'module'=>'Users',
          'action'=>'Authenticate',
          'return_module'=>'Users',
          'return_action'=>'Login',
        ];
my $res = $ua->request($req);
print Dumper(\$res);
if ($res->is_success){
        print $res->as_string;
}

when i try this code i am not able to login to the application
it says 302
that is found , but with no data
i want to do like if i post username/password with all required things then it should return the home page of the application

and keep the connection live to move other parts of the application

Thanks
maxj

wickedxter Jul 13th, 2009 10:31 pm
Re: LWP for login to an web application
 
try print $res->content; rather then print $res->as_string. The only thing is that, if the post successful then it will retrieve the contents of that whole page as source code (HTML format). you can save the ref. to a string if need be.


All times are GMT -4. The time now is 10:26 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC