我尝试新的PayPal REST API,并且想要学习如何使用PHP/curl。PayPal OAuth2 REST API基础
我是新来使用curl所以请原谅......
从PayPal的开发者文档,我收集所需的字段和我放在一起如下:
$ch = curl_init();
$postDataArray = array("grant_type=client_credentials");
curl_setopt($ch, CURLOPT_POSTFIELDS, $postDataArray);
curl_setopt($ch, CURLOPT_URL, 'https://api.sandbox.paypal.com/v1/oauth2/token');
$headerArray = array('Accept: application/json','Accept-Language: en_US');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headerArray);
$clientID_Secret = "clientID:secret";
curl_setopt($ch, CURLOPT_USERPWD, $clientID_Secret);
接下来的几行,我增加由于谷歌搜索。
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_COOKIEJAR, "my_cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "my_cookies.txt");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
print_r($result);
这不会返回任何内容。 请帮忙。
在这里你需要确保clientID和secret是不是字符串文字的值:$ clientID_Secret =“clientID:secret”; – Praveen 2013-03-12 19:12:29