我正在尝试使用此代码使用paypal的API获取旧的交易详情:
<?php
$info = 'USER=[username]'
.'&PWD=[password]'
.'&SIGNATURE=[signature]'
.'&METHOD=TransactionSearch'
.'&TRANSACTIONCLASS=RECEIVED'
.'&STARTDATE=2014-01-01T05:38:48Z'
.'&ENDDATE=2014-01-02T05:38:48Z'
.'&VERSION=94';
$curl = curl_init('https://api-3t.sandbox.paypal.com/nvp');
curl_setopt($curl, CURLOPT_FAILONERROR, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_POSTFIELDS, $info);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_POST, 1);
$result = curl_exec($curl);
if($result == FALSE) {
echo "cURL error: " . curl_error($curl);
}
parse_str($result, $result);
foreach($result as $key => $value){
echo $key.' => '.$value."<BR>";
}
我收到错误消息:
TIMESTAMP => 2014-07-01T10:57:55Z
CORRELATIONID => db47001bb195b
ACK => Failure
VERSION => 94
BUILD => 11562053
L_ERRORCODE0 => 10002
L_SHORTMESSAGE0 => Security error
L_LONGMESSAGE0 => Security header is not valid
L_SEVERITYCODE0 => Error
这段代码的最终结果是搜索查找特定事务的事务记录,并将该数据转发回程序的其余部分。
答案 0 :(得分:0)
无效的安全标头错误几乎总是与您的API凭据不正确相关。仔细检查您的API用户名,密码和签名。当您从沙箱移动到现场时,请务必更改凭据。