1,问题: 已经获得access_token,在使用access_token请求(发送一条微博)API接口时,报错
2,代码信息
/*发送一条微博*/ public function pushWeiboOnce($access_token,$status,$visible = 0,$list_id = "",$lat = "",$long = "",$annotations = "",$rip = "") { $data = array( 'access_token'=>$access_token, 'status'=>$status ); $headers = array(); $headers[] = "Content-Type:application/x-www-form-urlencoded"; $url = "https://api.weibo.com/2/statuses/update.json"; $result = $this->_requestPost($url,$data,true,$headers); $err = json_decode($result,true); return $err; } /*_requestPost*/ private function _requestPost($url,$data = array(),$ssl = true,$headers = array()) { $timeout = 60; $ch = curl_init($url); curl_setopt($ch,CURLOPT_SAFE_UPLOAD, false); curl_setopt($ch, CURLOPT_HEADER,0); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,$timeout); curl_setopt($ch, CURLOPT_POSTFIELDS,$data); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false); if(!empty($headers)){ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); } //检查服务器SSL证书中是否存在一个公用名 curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,2); if($ssl){ //发送ssl请求配置 //禁用后,将禁止从服务器验证 curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false); //检查服务器SSL证书中是否存在一个公用名 curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,2); } $result = curl_exec($ch); curl_close($ch); return $result; } /*调用*/ token确保已经获取 $content = "我是微博机器人=.=,来自勇哥的接口测试程序"; $result = $oauthWeibo->pushWeiboOnce($token,$content); print_r($result);
3,报错信息:
[error] => auth by Null spi! [error_code] => 21301 [request] => /2/statuses/update.json
4,相关信息,应用未提交审核,但是使用了测试账号也报错,回调地址也是正确的
文档地址:http://open.weibo.com/wiki/2/...
业精于勤,荒于嬉;行成于思,毁于随。