猿问

php微博登录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);

报错如图,求指导。

NULLmuke
浏览 2177回答 2
2回答

qq_大寒_2

报错 Fatal error: Call to undefined function curl_init() in  D:\wamp\www\test\one.php on line 17 $ch = curl_init();你是不是没开启curl_init()
随时随地看视频慕课网APP
我要回答