【发布时间】:2019-06-16 16:27:01
【问题描述】:
我这里有一个 PayPal IPN 脚本,但问题是,它正在正确接收 POST 请求,但是当它尝试向 PayPal 发出 CURL 请求时,似乎 PayPal 没有给出任何响应(甚至 @987654321 @ 或任何东西!)
这是我的代码:
<?php
// Format POST values
foreach($_POST as $name => $value) {
$data .= $name.'='.$value.'&';
}
$data = substr_replace($data, NULL, -1);
$data = urlencode($data);
// THE PROBLEM COMES HERE, I TRY TO MAKE A CURL REQUEST TO PAYPAL BUT NO RESPONSE RETURNED
$ch = curl_init('https://sandbox.ipnpb.paypal.com/cgi-bin/webscr');
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));
$res = curl_exec($ch);
$res = curl_close($ch);
file_put_contents('result.txt',$res);
// There is nothing in my result.txt file for $res , but $data returns the POST data PayPal gave me
?>
【问题讨论】:
标签: php paypal paypal-sandbox paypal-ipn