Re: Need libwww guru help please. "Can't call method "request" on an undefined value at ....."

Robert (robert@chalmers.com.au)
Tue, 16 Jan 2001 14:25:22 +1000


Hi Randal,  (replying to list only - someone may have an answer)
took your advice.
Sorry, same result.  The standalone program works fine. As a subroutine  it
fails.

Can't call method "request" on an undefined value at
/usr/local/lib/perl5/site_perl/5.6.0/LWP/UserAgent.pm line 227

Rewrote the code: (It is much easier to understand now....)

##############################  Makepayment via Visa
#################################################################
sub esecpay {

my $ua;
use HTTP::Request::Common;
use LWP::UserAgent;
#use LWP::Debug qw(+conns +trace +debug);
$ua = LWP::UserAgent->new;
$ua->agent("AgentName/0.1 " . $ua->agent);

#create request
my $req = (POST 'https://sec.aba.net.au/cgi-bin/service/authorise/test',
        [ secParams   =>
'https://sec.aba.net.au/merchant/test/testpayment.props',
          referenceID => 'new.domain.name',
          cardType    => 'ABA Test',
          cardNumber  => 'abasuccess',
          nameOnCard  => 'Robert Chalmers',
          expiryMonth => '3',
          expiryYear  => '2002',
          amount      => '45.00',
          resultURL   => 'http://www.chalmers.com.au/~robert/allvars.php3',
        ]);
$req->content_type('application/x-www-form-urlencoded');

#see what happens
print $ua->request($req)->as_string;

}
#################################  end of esecpay
################################################################

It's got me stumped.

Robert


> look into HTTP::Request::Common to create your requests.
> --
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777
0095
> <merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
> See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl
training!
>