Very helpful, but now I have that crazy HTTP 302 error. I had to add use HTTP::Cookies; into the script again because it didn't like not having it.
Any ideas why I get the error and/or how do I get around it? Also, Ilya you had simple_request on the second post. Did you mean to have just 'request' there? And do I not need "my $request = " on the first "$ua->request(POST..." line? Or the "$ua->cookie_jar" line?
What I am trying to accomplish is to update my user information on a website that requires a login. So first I need to login and then use the cookie info for posting my user information on a different form. THANKS!
#!/usr/lib/perl -w
use strict;
use LWP::UserAgent;
use HTTP::Request::Common;
# didn't work without this use statement
use HTTP::Cookies;
my $ua = LWP::UserAgent->new;
$ua->cookie_jar(HTTP::Cookies->new(file => 'cookie_jar', autosave =>1)
+);
$ua->request(POST "http://www.sitedomain.com/login.cfm",
{
username =>'abcuser',
userpass =>'abc123',
submit =>'Submit'
});
my $request = $ua->request(POST "http://www.sitedomain.com/editinfopag
+e.cfm",
{
firstname =>"MyName",
lastname =>"MyLastName",
company =>"companyname",
address =>"111 East 222 South",
city =>"Provo",
state =>"UT",
zip =>"99999"
});
print $request->is_success ? "worked\n" : "failed\n";
# this shows me that I have the following error:
# HTTP/1.1 302 (Found) Object Moved...
print $request->as_string;