I am trying to login in to a site and then post to a page while still logged in. I can log in fine, but as soon as I try to do the second post I am stuck with an HTTP 1.1/302 error as follows:
HTTP/1.1 302 (Found) Object Moved Connection: close Location: defaultpage.cfm?sid=99999999999&CFID=99999&CFTOKEN=9999999 Server: Microsoft-IIS/5.0 Content-Length: 196 Content-Type: text/html Client-Date: Tue, 21 May 2002 06:50:00 GMT Client-Response-Num: 1 Title: Document Moved
Object Moved
This document may be found here
If anyone has any suggestions, maybe even another way to do it, please share. Thanks! My code is as follows (with login/site info taken out):
#!usr/bin/perl -w
use LWP::UserAgent;
use HTTP::Cookies;
use HTTP::Request::Common;
my $ua = LWP::UserAgent->new;
$ua->cookie_jar(HTTP::Cookies->new(file => 'cookie_jar', autosave =>1)
+);
my $r = $ua->simple_request(POST "http://www.sitedomain.com/login.cfm"
+,
{
username =>'abcuser',
userpass =>'abc123',
submit =>'Submit'
});
while ($r->is_redirect) {
my $u = $r->header('location') or die "missing location: ",
$r->as_string;
#print "redirecting to $u\n";
$u=~s/^\.+/http\:\/\/www\.sitedomain\.com/s;
$r = $ua->simple_request(GET $u);
}
my $r = $ua->simple_request(POST "http://www.sitedomain.com/page.cfm",
{
firstname =>"Michael",
lastname =>"Jensen",
company =>"companyname",
address =>"111 East 222 South",
city =>"Provo",
state =>"UT",
zip =>"99999"
});
$b = $r->as_string;
if ($r->is_success) {
$a = "worked";
}
else{
$a = "failed";
}
print "b is $b";
Michael Jensen
InBlosam Productions
http://www.inblosam.com