@Lee点以正确的方式,但如果u使用老版本的PHP它不会工作。但李版本不会显示错误。改用这些,我只添加错误部分,看看发生了什么。
$ch = curl_init();
$clientId = "";
$secret = "";
curl_setopt($ch, CURLOPT_URL, "https://api.sandbox.paypal.com/v1/oauth2/token");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $clientId.":".$secret);
curl_setopt($ch, CURLOPT_POSTFIELDS, "grant_type=client_credentials");
$result = curl_exec($ch);
$err = curl_error($ch);
$access_token="";
if ($err) {
echo "cURL Error #:" . $err;
}
else
{
$json = json_decode($result);
// print_r($json->access_token);
$access_token = $json->access_token;
}
如果妳有老版本的PHP是更多钞票它不会工作,它会显示这个错误:
cURL Error #:error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure
就栈溢出了! Here they discuss the problem
不幸的是,好像Paypal已经从Github上删除了他们的REST API curl示例。 –
这是完美的拯救了我的生活。 –
tnkx哥们你救了我的时间和生命也 –