當前位置:首頁 > 資訊 > 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號
广东25选5开奖结果