贝宝沙盒卷曲授权

时间:2018-06-23 13:08:18

标签: php curl paypal paypal-sandbox

我使用RESTful PayPal API RESTful开发了脚本。 在我的本地计算机上,效果很好! 但是不在我的网站上:(我也不理解为什么。 卷曲的功能似乎是问题所在。

这是我的PHP代码的一部分:

<?php
$id = "AAAAAAAAAAAAAAAAAAA";
$secret = "ZZZZZZZZZZZZZZZ";   
$ch = curl_init();

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL, "https://api.sandbox.paypal.com/v1/oauth2/token");  //DUMMY
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "grant_type=client_credentials");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, $id . ":" . $secret);

$headers = array();
$headers[] = "Accept: application/json";
$headers[] = "Accept-Language: en_US";
$headers[] = "Content-Type: application/x-www-form-urlencoded";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
$data = json_decode($result);

echo '<br>ch='.$ch;
echo '<br>r='.print_r($result,1);
curl_close ($ch);

在我的本地服务器上,它返回以下响应:

  

ch =资源ID#2 r = {“作用域”:“ https://api.paypal.com/v1/payments/。*   https://uri.paypal.com/services/payments/refund   https://uri.paypal.com/services/applications/webhooks   https://uri.paypal.com/services/payments/payment/authcapture   https://uri.paypal.com/payments/payouts   https://api.paypal.com/v1/vault/credit-card/。*   https://uri.paypal.com/services/disputes/read-seller   https://uri.paypal.com/services/subscriptions   https://uri.paypal.com/services/disputes/read-buyer   https://api.paypal.com/v1/vault/credit-card openid   https://uri.paypal.com/services/disputes/update-seller   https://uri.paypal.com/services/payments/realtimepayment“,” nonce“:” 2018-06-23T12:52:59Zi8vohQXD6WC0NzGJDDmOYY3C94kgmEfORAs9lAMxBW0“,” access_token“:” XXXXXXXXXXXXXXXXXXXXXX“,” token_type“:” Bearer“,” app80T284“:” expires_in“:32078}

酷! :)

但是在我的网站上,它返回:

  

ch =资源ID#2 r =

为什么?我真的不明白:(((

有人可以帮我吗?

谢谢!

1 个答案:

答案 0 :(得分:0)

抱歉,我发现了问题 在我的网站上,我使用的是Openssl 0.9版本,而使用Paypal时,我必须使用的是Opennssl 1.0版本...