I developed my script with PayPal APIs RESTful for payments. On my local computer, it works great! But not on my website :( and I don't undestand why. It' the curl fonction which seems to be the problem.
Here's a part of my code in 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);
On my local server, it returns the following response:
ch=Resource id #2 r={"scope":" 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":"XXXXXXXXXXXXXXXXXXX","token_type":"Bearer","app_id":"APP-80W284485P519543T","expires_in":32078}
Cool! :)
But on my website, it returns :
ch=Resource id #2 r=
Why ? I really don't understand :(((
Can someone help me please ?
Thanks!
哦,对不起,我发现了问题在我的网站上,我使用的是Openssl 0.9版本,而使用贝宝时,我必须使用的是Opennssl 1.0版本...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.