zoukankan      html  css  js  c++  java
  • 微信网站应用扫码登陆

    微信网站应用扫码登陆

    1、js二维码code

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>微信扫码登陆</title>
        <script type="text/javascript" src="/app/static/wxLogin.js"></script>
    </head>
    <body>
        <div id="login_container">
        </div>
        <script type="text/javascript">
            var obj = new WxLogin({
                self_redirect:true,
                id:"login_container", 
                appid: "", 
                scope: "snsapi_login", 
                redirect_uri: "{$redirect_uri}",
                state: "",
                style: "black",
                href: "LmltcG93ZXJCb3ggLnFyY29kZSB7d2lkdGg6IDIwMHB4O30KLmltcG93ZXJCb3ggLnRpdGxlIHtkaXNwbGF5OiBub25lO30KLmltcG93ZXJCb3ggLmluZm8ge3dpZHRoOiAyMDBweDt9Ci5zdGF0dXNfaWNvbiB7ZGlzcGxheTogbm9uZX0KLmltcG93ZXJCb3ggLnN0YXR1cyB7dGV4dC1hbGlnbjogY2VudGVyO30g"
                });
        </script>
    </body>
    </html>
    
    

    2、接受code,生成openid

    //获取微信二维码扫码登陆
    		$tokens="https://api.weixin.qq.com/sns/oauth2/access_token?appid=&secret=&code={$code}&grant_type=authorization_code";
    		$this->oLogAct->add("微信扫码登陆获取二维码token地址" . json_encode($tokens));
    		$tokens=$this->setGet($tokens);
    		$this->oLogAct->add("微信扫码登陆获取二维码token信息" . json_encode($tokens));
    		if (empty($tokens)) {
    		   return self::setMsg(500, '登录失败!');
    		}
    		
    		$openid=base64_encode($this->encryptData($tokens['openid']));
    
    
    
  • 相关阅读:
    Shell脚本编程之Shell函数
    Shell脚本编程之流程控制
    Shell脚本编程之Shell命令
    MySQL5.6的optimizer_trace
    Cgroup
    Python的__main__.py用法
    Git提交到github上
    mysql timeout
    数据库大牛
    update and的坑
  • 原文地址:https://www.cnblogs.com/mengluo/p/15410815.html
Copyright © 2011-2022 走看看