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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTTP::request question

Status
Not open for further replies.

audiopro

Programmer
Joined
Apr 1, 2004
Messages
3,165
Location
GB
I am entering unknown waters (for me) with the following script and trying to get my head round what it is doing.
I think it goes like this....
I post a form to this script,
STDIN is read in from the form and an additional param 'cmd' is added to it,
The entire new query string is posted to the address in the HTTP::Request line,
Another string '$status' is returned from that call.
Code:
read (STDIN, $query, $ENV{'CONTENT_LENGTH'});
$query .= '&cmd=_notify-validate';

# post back to PayPal system to validate
use LWP::UserAgent;
$ua = new LWP::UserAgent;
$req = new HTTP::Request 'POST','[URL unfurl="true"]http://www.paypal.com/cgi-bin/webscr';[/URL]
$req->content_type('application/x-[URL unfurl="true"]www-form-urlencoded');[/URL]
$req->content($query);
$res = $ua->request($req);
$status = $res->content;
The script functions but I am getting an uexpected returned value and am making sure I am looking at the correct section.
I have checked the function HTTP::request in cpan but as always, the terminology is a little confusing.

Keith
 
Obviously there are often more than one way to use most modules, but this is the method that I prefer for posts:

Code:
[url=http://perldoc.perl.org/functions/use.html][black][b]use[/b][/black][/url] [green]HTTP::Request::Common[/green] [red]qw([/red][purple]POST[/purple][red])[/red][red];[/red]
[black][b]use[/b][/black] [green]LWP::UserAgent[/green][red];[/red]

[gray][i]# Create a HTTP POST request[/i][/gray]
[url=http://perldoc.perl.org/functions/my.html][black][b]my[/b][/black][/url] [blue]$ua[/blue] = new LWP::UserAgent[red];[/red]
[blue]$ua[/blue]->[maroon]agent[/maroon][red]([/red][red]"[/red][purple]Your User Agent of Love/1.0[/purple][red]"[/red][red])[/red][red];[/red]

[black][b]my[/b][/black] [blue]$req[/blue] = POST [red]"[/red][purple][URL unfurl="true"]http://your.website.of.love.com/[/URL][/purple][red]"[/red], [red][[/red]
	[purple]PARAM1[/purple]		=> [red]"[/red][purple]WAY![/purple][red]"[/red],
	[purple]PARAM2[/purple]		=> [red]"[/red][purple]unhuh![/purple][red]"[/red],
	[purple]PARAM3[/purple]		=> [red]"[/red][purple]Oh nevermind...[/purple][red]"[/red],
[red]][/red][red];[/red]

[black][b]my[/b][/black] [blue]$res[/blue] = [blue]$ua[/blue]->[maroon]request[/maroon][red]([/red][blue]$req[/blue][red])[/red][red];[/red]
[tt]------------------------------------------------------------
Other Modules used :
[ul]
[li]HTTP::Request::Common[/li]
[li]LWP::UserAgent[/li]
[/ul]
[/tt]

- Miller
 
This is a script supplied by paypal which I am trying to get fully working. The script is full of security holes (no strict etc.) so will be re-written once I get the thing working. I was just checking I have the right idea of how it works.
The problem I have is that the whole thing works, confirmation emails and everything but the call returns INVALID rather than the expected VERIFIED.


Keith
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top