标签:dev 性能 编译 nat 分离 系统版本 翻译 image 机制
1.方式一
//登录 public function login(){ $config=config(‘ding‘); $app = new Application($config); $response = $app->oauth->use(‘app-01‘)->withQrConnect()->redirect(); return $response; } //登录回调 public function loginCallback(){ $state=Request::param(‘state‘); $config=config(‘ding‘); $app = new Application($config); $user = $app->oauth->use(‘app-01‘)->stateless()->user(); dump($user);die; }
2.方式二
放到需要展示二维码的地方,回调同上
<div id="login_container"></div> <script> var obj = DDLogin({ id:"login_container", goto: encodeURIComponent("https://oapi.dingtalk.com/connect/oauth2/sns_authorize" + "?appid=dingoayms9jntgrrcofsre&response_type=code&scope=snsapi_login&state=STATE&redirect_uri="+"http://datav.site888.cn/dingd/Index/loginCallback"), //请参考注释里的方式 style: "border:none;background-color:#FFFFFF;", width : "365", height: "400" }); var handleMessage = function (event) { var origin = event.origin; console.log("origin", event.origin); if( origin == "https://login.dingtalk.com" ) { //判断是否来自ddLogin扫码事件。 var loginTmpCode = event.data; //获取到loginTmpCode后就可以在这里构造跳转链接进行跳转了 var url2="https://oapi.dingtalk.com/connect/oauth2/sns_authorize" + "?appid=dingoayms9jntgrrcofsre&response_type=code&scope=snsapi_login" + "&state=STATE&redirect_uri="+encodeURIComponent("https://oapi.dingtalk.com/connect/oauth2/sns_authorize" + "?appid=dingoayms9jntgrrcofsre&response_type=code&scope=snsapi_login&state=STATE&redirect_uri="+"http://datav.site888.cn/dingd/Index/loginCallback")+"&loginTmpCode="+loginTmpCode; window.location.href=url2; console.log("loginTmpCode", loginTmpCode); } }; if (typeof window.addEventListener != "undefined") { window.addEventListener("message", handleMessage, false); } else if (typeof window.attachEvent != "undefined") { window.attachEvent("onmessage", handleMessage); } </script>
标签:dev 性能 编译 nat 分离 系统版本 翻译 image 机制
原文地址:https://blog.51cto.com/9334358/2518530