微信网页授权+获取用户基本信息+强制关注+JSSDK分享参数

网页授权+获取用户基本信息+强制关注+JSSDK分享参数

 

    //支付宝红包口令列表
    public function view(){
        $openid = "";

        Vendor('Weixin.weixinclass');
        $weixin = new \weixin();
        if (!isset($_GET["code"])){
            $redirect_url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
            $jumpurl = $weixin->oauth2_authorize($redirect_url, "snsapi_base", "123");
            Header("Location: $jumpurl");
            exit();
        }else{
            // var_dump($_GET);
            $access_token_oauth2 = $weixin->oauth2_access_token($_GET["code"]);
            $openid = $access_token_oauth2['openid'];
            $userinfo = $weixin->get_user_info($openid);
            // var_dump($userinfo);
            if ($userinfo["subscribe"] == 0){
                Header("Location: ".U('App/qrcode',array('id'=>'88')));
            }else{
                Vendor('Weixin.wxjssdk');
                $weixin2 = new \class_weixin();
                $signPackage = $weixin2->GetSignPackage();
                $shareNews = array("Title" =>"方倍工作室微信公众账号", "Description"=>"回复红包抢红包", "PicUrl" =>'http://www.fangbei.org/alihb.jpg', "Url" =>$signPackage['url']);

                $alipassword = D('Alipassword');
                $list = $alipassword->where('status=1')->limit(100)->order('starttime desc')->select();
                $this->assign('signPackage', $signPackage);
                $this->assign('shareNews', $shareNews);
                // $userinfo["headimgurl"] = str_replace("/0","/46",$userinfo["headimgurl"]);
                $this->assign('userinfo', $userinfo);
                $this->assign('curtime', date("Y-m-d H:i",time()));
                $this->assign('title', "最新最全的支付宝红包口令");
                $this->assign('list', $list);
                $this->display();
            }
        }
    }

 

上一篇:阶段5 3.微服务项目【学成在线】_day16 Spring Security Oauth2_04-用户认证技术方案-SpringSecurityOauth2


下一篇:阶段5 3.微服务项目【学成在线】_day16 Spring Security Oauth2_05-SpringSecurityOauth2研究-搭建认证服务器