Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LWP::UserAgent Question

Status
Not open for further replies.

Panthaur

IS-IT--Management
Jul 26, 2002
78
US
I'm using the following portion of code in a program for IPN Validation with Paypal:

-----------------------
$query = "the information that paypal sends the server when a person purchases something";

use LWP::UserAgent;
$useragent = new LWP::UserAgent;
$request = new HTTP::Request 'POST','
$request->content_type('application/x-$request->content($query);
$results = $useragent->request($request);
-----------------------

It is for an IPN authorization script on a website i'm working on. My problem is that I should be getting a code back from the http post that I am doing, but instead I am getting this hash shown below:

HTTP::Response=HASH(0x8280e30)

I should be getting back the words VERIFIED or INVALID, but i'm getting this gibberish instead? Can anyone tell me what I am doing wrong in my script? Just so everyone knows, it is a redhat 7.2 server with PERL 5.6.1.

The script is posting back to Paypal with the proper information, but I can't seem to read the response that I need to validate the transaction with Paypal. If someone has a better snippet of code to do that same thing I am trying to do, it would be appreciated.

Thanks,
Panthaur
 
You are receiving a response object which has methods to recover the info you need. The following (from the HTTP::Response manpage) covers the common cases:

Code:
        $results = $useragent->request($request);
        if ($results->is_success) {
            print $results->content;
        } else {
            print $results->error_as_HTML;
        }

There are other methods covering the more complex cases.

PS - it's not just you: does look confusing first time through ;-)

Yours,



fish




"As soon as we started programming, we found to our surprise that it wasn't as
easy to get programs right as we had thought. Debugging had to be discovered.
I can remember the exact instant when I realized that a large part of my life
from then on was going to be spent in finding mistakes in my own programs."
--Maurice Wilk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top