问答详情
源自:-

code到access_token出错

$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);

报错:http://img.mukewang.com/57836f430001e9fc03440223.jpg请问什么原因?谢谢大家

提问者:NULLmuke 2016-07-11 18:05

个回答