LWP for login to an web application

Reply

Join Date: Jun 2009
Posts: 1
Reputation: maxjackie is an unknown quantity at this point 
Solved Threads: 0
maxjackie maxjackie is offline Offline
Newbie Poster

LWP for login to an web application

 
0
  #1
Jun 22nd, 2009
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

  1. use HTTP::Request::Common qw(POST);
  2. use LWP::UserAgent;
  3. use Data::Dumper;
  4.  
  5. $ua = LWP::UserAgent->new(keep_alive=>1);
  6.  
  7. my $req = POST "http://servername.com:5002/index.php",
  8. ['user_name' => 'username',
  9. 'user_password'=>"password",
  10. 'module'=>'Users',
  11. 'action'=>'Authenticate',
  12. 'return_module'=>'Users',
  13. 'return_action'=>'Login',
  14. ];
  15. my $res = $ua->request($req);
  16. print Dumper(\$res);
  17. if ($res->is_success){
  18. print $res->as_string;
  19. }

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
Last edited by maxjackie; Jun 22nd, 2009 at 3:42 pm.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 15
Reputation: wickedxter is an unknown quantity at this point 
Solved Threads: 0
wickedxter wickedxter is offline Offline
Newbie Poster

Re: LWP for login to an web application

 
0
  #2
Jul 13th, 2009
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC