当前位置:首页 > 资讯 > info6 > 正文

微信获取用户详细信息

发表于: 2017-06-13 ? 作者:chen782079048 ? 来源:转载 ? 浏览:
摘要: //详细授权1 publicfunctiongrant(){ //1户同意授权获取code $appid='8888888888888888888888888'; $redirect_uri=urlencode("http://wwwwwwwwwwwww/fruits/public/index.php/home/wei/role"); $url="https://open.weixin.qq.co
 //详细授权1
    public function grant(){
        //1户同意授权  获取code
        $appid='8888888888888888888888888';
        $redirect_uri=urlencode("http://wwwwwwwwwwwww/fruits/public/index.php/home/wei/role");
        $url="https://open.weixin.qq.com/connect/oauth2/authorize?appid=".$appid."&redirect_uri=".$redirect_uri."&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect";
        header('location:'.$url);
    }
    ///详细授权2
    public function role(){
        //2 通过code 换取网页授权access_token
        $appid="8888888888888888888888";
        $secret="788888888888888888888888882";
        $code=$_GET['code'];
        $url="https://api.weixin.qq.com/sns/oauth2/access_token?appid=".$appid."&secret=".$secret."&code=".$code."&grant_type=authorization_code";
        //3 获取用户openId
        $res=$this->httpCurl($url,'get');
        $openid=$res['openid'];
        $access_token=$res['access_token'];
        //拉去用户的详细信息
        $urls="https://api.weixin.qq.com/sns/userinfo?access_token=".$access_token."&openid=".$openid."&lang=zh_CN";
        $reslist=$this->httpCurl($urls);
        var_dump($reslist);
    }


微信获取用户详细信息

版权所有 IT知识库 CopyRight ? 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号