我正试图通过PHP/cURL和OAuth2在中国微博网站新浪微博上发布一个OAuth2。我遇到了这个错误:
{“错误”:“auth!”,"error_code":21301,“请求”:“/2/statuse/update.json”}
我的PHP:
<?php
$ch = curl_init('https://api.weibo.com/2/statuses/update.json');
$headers = array(
'Authorization: Bearer '.$access_token,
'Content-Type: application/x-www-form-urlencoded');
$postData = array('access_token' => '2.00x123456789', 'status' => 'hello');
curl_setopt_array($ch, array(
CURLOPT_SSL_VERIFYPEER => FALSE,
CURLOPT_SSL_VERIFYHOST => TRUE,
CURLOPT_POST => TRUE,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_POSTFIELDS => $postData
));
$response = curl_exec($ch);
echo $response;
curl_close($ch);
?>我使用OAuth2作用域all授权应用程序,令牌是有效的。错误的原因是什么?
发布于 2014-02-25 17:55:49
删除http标头
'Content-Type: application/x-www-form-urlencoded'
将员额字段改为:
CURLOPT_POSTFIELDS => http_build_query($postData)现在开心点!
https://stackoverflow.com/questions/22021873
复制相似问题