【发布时间】:2014-08-23 15:03:56
【问题描述】:
我正在尝试使用 PHP 和 cURL 从 PayPal 请求身份验证令牌以创建付款。
我的代码是:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.sandbox.paypal.com/v1/oauth2/token");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Accept-Language: en_US'
));
curl_setopt($ch, CURLOPT_USRPWD, 'xxxx:xxxx');
curl_setopt($ch, CURLOPT_POSTFIELDS, 'grant_type=client_credentials');
$output = curl_exec($ch);
?>
我得到了回应:
curl_setopt() expects parameter 2 to be long, string given in Users/anth/sites/abyss/auth.php on line 11
{"error":"invalid_client","error_description":"Invalid client credentials"}
第 11 行是:
curl_setopt($ch, CURLOPT_USRPWD, 'xxxx:xxxx');
我已经检查了我的客户 ID 和密码,它们都很好。
有谁知道我是不是使用了错误的语法?
谢谢
【问题讨论】: