我遇到了使这段代码正常工作的麻烦。它不断返回" API凭据不正确"但是在Paypal API Explorer中使用相同的凭据就可以了!
$headers = array(
"X-PAYPAL-SECURITY-USERID" => "****",
"X-PAYPAL-SECURITY-PASSWORD" => "****",
"X-PAYPAL-SECURITY-SIGNATURE" => "****",
"X-PAYPAL-APPLICATION-ID" => "APP-80W284485P519543T",
"X-PAYPAL-REQUEST-DATA-FORMAT" => "JSON",
"X-PAYPAL-RESPONSE-DATA-FORMAT" => "JSON",
"X-PAYPAL-DEVICE-IPADDRESS" => "****",
"X-PAYPAL-REQUEST-SOURCE" => "merchant-php-sdk-2.0.96"
);
$data = array(
'emailAddress' => 'Anonimandro-buyer@gmail.com',
'matchCriteria' => 'NONE'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://svcs.sandbox.paypal.com/AdaptiveAccounts/GetVerifiedStatus");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = json_decode(curl_exec($ch),true);
print_r( $response );
curl_close ($ch);
答案 0 :(得分:0)
用于curl调用的标头数组不正确。它应该是:
$headers = array(
"X-PAYPAL-SECURITY-USERID: ****",
"X-PAYPAL-SECURITY-PASSWORD: ****",
"X-PAYPAL-SECURITY-SIGNATURE: ****",
"X-PAYPAL-APPLICATION-ID: APP-80W284485P519543T",
"X-PAYPAL-REQUEST-DATA-FORMAT: JSON",
"X-PAYPAL-RESPONSE-DATA-FORMAT: JSON",
"X-PAYPAL-DEVICE-IPADDRESS: ****",
"X-PAYPAL-REQUEST-SOURCE: merchant-php-sdk-2.0.96"
);