Hello,
Can anyone who is a master of php and perl (or thereabouts) please translate this perl script for me into php.
More specifically, is there anything in this perl script that cannot be achieved with php.
I need this functionality, but in php if possible, because that's what all the rest of my code is in.
The script is from paypal.com (merchant services) and is meant to be used as a validation check - to make sure the customer's payment transaction was successful:
#!/usr/local/bin/perl
read the post from PayPal system and add 'cmd'
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','https://www.paypal.com/cgi-bin/webscr';
$req->content_type('application/x-www-form-urlencoded');
$req->content($query);
$res = $ua->request($req);
split posted variables into pairs
@pairs = split(/&/, $query);
$count = 0;
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$variable{$name} = $value;
$count++;
}