Re: Changing perl to PHP
| From: | Jason Brooke | Date: | Wed, 12 Sep 2001 06:44:48 +0000 |
| Subject: | Re: Changing perl to PHP | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-67003@lists.php.net to get a copy of this message | ||
> # 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);
Untested, using the curl part of the online manual (
http://www.php.net/manual/en/ref.curl.php )
as a reference:
foreach ($HTTP_POST_VARS as $key=>$value) $query .= "$key=$value&";
$query .= "cmd=_notify-validate";
if ($ch = curl_init("https://www.paypal.com/cgi-bin/webscr"))
{
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
curl_exec($ch);
curl_close($ch);
}
jason