$code=$_GET['code']; //echo $code; exit; $url='https://api.weibo.com/oauth2/access_token'; $redirect_uri='...'; $appid='...'; //$url='https://api.weibo.com/oauth2/authorize?client_id='.$appid.'&redirect_uri='.$redirect_uri.'&response_type=code'; $data=array( 'client_id'=>'...', 'client_secret'=>'...', 'grant_type'=>'authorization_code', 'code'=>$code, 'redirect_uri'=>'...' ); //$postfields=http_build_query($data); $ch=curl_init(); curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_POST,1); curl_setopt($ch,CURLOPT_POSTFIELDS,$data); $output=curl_exec($ch); if(curl_errno($ch)){ return curl_error($ch); } curl_close($ch); $arr=json_decode($output,true); var_dump($arr);
qq_大寒_2