1

因为我没有让这段代码工作,老实说我不知道​​,为什么,也许你们中的一个可以给我一些建议?我得到的唯一值是“失败”

到目前为止我已经尝试过:

  • 身份令牌绝对正确
  • $tx 有一个值
  • $tx 没有被使用超过 5 次

这是我的代码:

<?php

$tx = $_GET['tx'];
$identity = '############################'; 

// 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' => $identity,
);

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);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Host: www.sandbox.paypal.com"));

// Execute request and get response and status code
$response = curl_exec($ch);
$status   = curl_getinfo($ch, CURLINFO_HTTP_CODE);

// Close connection
curl_close($ch);
if($status == 200 AND strpos($response, 'SUCCESS') === 0)
{
    echo $response;
} else {
    echo "error... :(";
    echo $response;
    exit;
}
?>
 

我使用 curl 因为我发现的任何其他片段都没有返回任何内容。

4

0 回答 0