【发布时间】:2016-06-18 10:50:47
【问题描述】:
下面是我使用 paypal PDT 的 paypal 接收文件的代码
<?php
$tx = $_GET['tx'];
$ID = $_GET['cm'];
$amount = $_GET['amt'];
$currency = $_GET['cc'];
$auth = "#####";
// Init cURL
$ch = curl_init();
// Set request options
$url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
$fields = array(
'cmd' => '_notify-synch',
'tx' => $tx,
'at' => $auth
);
curl_setopt($ch, CURLOPT_CAINFO, 'cacert.pem');
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, http_build_query($fields));
curl_setopt($ch,CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch,CURLOPT_HEADER, FALSE);
// Execute request and get response and status code
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Close connection
curl_close($ch);
print_r($response);
if($status == 200 AND strpos($response, 'SUCCESS') === 0)
{
//wp_redirect(home_url('/account'));
exit;
} else {
// wp_redirect(home_url());
exit;
}
?>
我已经尝试了很多次了..但它仍然抛出错误...我有 测试服务器的 curl 及其与其他文件的工作......任何人都可以 知道为什么这不起作用
每当我尝试 print_r th 响应时..它是空的并且什么都不显示
【问题讨论】:
-
"它仍然抛出错误" -> 如果您不提供错误,我们将无法提供帮助?
-
它抛出了什么错误?使用curl_errors() 获取更多详细信息。仅供参考,最好使用Guzzle 而不是普通的
curl。它将使您免于调试。 -
对不起,让我澄清一下……它什么也没显示……我的意思是绝对没有……即使我打印了响应。在 print_r 上显示为 0
-
0 ==
false- 您的请求不成功。检查return values -
@LukasHajdu 我有 print_r 响应和它的空..我的意思是什么都没有打印