我目前正在尝试使用Buffer API,但我甚至无法让CURL返回错误消息。
我在print_r
上尝试了$resp
,但仍然只是一个空白页。
P.S我已经用phpinfo检查过我实际上现在已经启用了curl,它是版本7.30.0
if(isset($_GET['code'])){
$code = "REMOVED";
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => 'http://api.bufferapp.com/1/oauth2/token.json',
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => array(
'client_id' => 'REMOVED',
'client_secret' => 'REMOVED',
'redirect_uri' => 'http://localhost/example',
'code' => 'REMOVED',
'grant_type' => 'authorization_code'
)
));
$resp = curl_exec($curl);
curl_close($curl);
}
编辑:
我在关闭curl之前添加了以下代码行
echo curl_errno($curl);
echo curl_error($curl);
这是返回
60SSL证书问题:无法获得本地颁发者证书
答案 0 :(得分:0)
当您直接将数组传递给CURLOPT_POSTFIELDS
时,它将其视为多部分表单发布请求。在数组上使用函数http_build_query
。
CURLOPT_POSTFIELDS => http_build_query( array(
'client_id' => 'REMOVED',
'client_secret' => 'REMOVED',
'redirect_uri' => 'http://localhost/example',
'code' => 'REMOVED',
'grant_type' => 'authorization_code'
))