koryw has asked for the wisdom of the Perl Monks concerning the following question:
I using perl, v5.6.1 and LWP with Crypt::SSLeay installed. Here's the error and my code below. Does any one know a solution, thanks in advance.
ERROR: Can't locate object method "requests_redirectable" via package "LWP::UserAgent" (perhaps you forgot to load "LWP::UserAgent"?) at /home/tranx/cgi-bin/clearinghouse.pl line 39 Its complaining about this line: push @{$ua->requests_redirectable}, 'POST';
#!/usr/bin/perl #This Perl script sends a secure HTTP POST Method data #to authenticate to the National Student Clearinghouse #This process only works using the POST Http method. #Username, Social Security Number, and Password are sent to the Cleari +nghouse #Site. print "Content-type: text/html\n\n"; #Perl Modules that are used in this script use strict; use CGI; #use HTTP::Request::Common qw(POST); use HTTP::Request; use HTTP::Response; use LWP::UserAgent; my $query = CGI->new(); my $username = $query->param('user_id'); my $ssn = $query->param('qu'); my $password = $query->param('password'); #Referral link that must match what Clearinghouse has recorded #that we are referring to them from. my $referer = 'https://lamp1s.isu.edu/cgi-bin/clearinghouse.pl'; #Secure Clearhousing Link that the student content is validated at. my $destURL = 'https://www.studentclearinghouse.org/secure_area/ref_st +udents.asp'; #Creating Virtual server connection my $ua = new LWP::UserAgent; #Defining the browser were using $ua->agent('Mozilla/5.0 [en] (Windows NT 5.1; U)'); #Create the HTTP POST Secure URL link my $request = HTTP::Request->new(POST => $destURL); $request->content_ +type('application/x-www-fo rm-urlencoded');$request->content('user_id='.$username.'&password='.$p +assword.'&qu='.$ssn);$requ est->referer($referer); #Turning on redirect with the POST Method only push @{$ua->requests_redirectable}, 'POST'; #Submitting the link for verfication my $response = $ua->request($request); #Verifying if everthing worked, if not #an error will be generated back to the browser. #If everything worked Student should be #logged into the National Student Clearing House Site if (! $response->is_success) { print <<EOF; <html> <head> <title>Transcript Verification Request</title> </head> <body> <div align="center"> <h1>Error submitting to Student Clearinghouse</h1> EOF print $ua->is_protocol_supported( 'https' ). "<BR>"; print <<EOF; </div> </body> </html> EOF } else { print $response->content; } exit;
Edit by castaway - added code tags
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Lwp:UserAgent Error
by Thilosophy (Curate) on Nov 30, 2004 at 02:41 UTC |