Qrcode生成二维码链接地址,网页授权获取微信用户信息
来源:互联网 发布:常用数据库管理系统 编辑:程序博客网 时间:2024/06/06 20:05
(1)一个简单的二维码地址生成使用easywechat扫描获取微信用户的信息:
首先生成二维码链接这里引用的QrCode生成的
QrCode::size(300)->generate($url]);url为扫描二维码所跳转的地址
(2)当用户扫描二维码跳转至后台处理方法,我这里这样引用
public function getWxUserOpenid(Request $request){ //此处判断是否是微信浏览器 $user_agent = $_SERVER['HTTP_USER_AGENT']; if (strpos($user_agent, 'MicroMessenger') === false) { $targetUrl=如果不是直接越过授权,跳至需要授权的页面地址; return redirect()->away($targetUrl); }else{ $options = [ 'debug' => true, 'app_id' => "你的appid", 'secret' => "你的secret", 'token' => '你的token', 'oauth' => [ 'scopes' =>['snsapi_userinfo'], 'callback' => "授权回调URL地址", ], 'log' => [ 'level' => 'debug', 'file' => storage_path('logs/campaign'.date('Ymd').'.log'), ], ]; $app = new Application($options); $oauth = $app->oauth; if (empty(Session::get('wechat_user'))) { $target_url= 需要授权才能访问的页面; Session::put('target_url',$target_url); return $oauth->redirect(); } $user = Session::get('wechat_user'); } }
(3)授权回调页处理:
public function getCallback() { $config = [ 配置详情 ]; $app = new Application($config); $oauth = $app->oauth; $user = $oauth->user(); Session::put('user',$user); Session::put('wechat_user',$user->toArray()); $target_Url = empty(Session::get('target_url')) ? '/' : Session::get('target_url'); return redirect($target_Url); }
easywechat网页授权文档地址:https://easywechat.org/zh-cn/docs/oauth.html
如果对你有帮助,就顶我!
2 0
- Qrcode生成二维码链接地址,网页授权获取微信用户信息
- 微信网页授权—获取用户信息
- 微信网页授权(获取用户信息)
- 微信网页授权后台获取用户信息
- 微信开发-网页授权获取用户信息
- 微信网页授权及获取用户信息
- Java微信网页授权获取用户信息 微信分享
- 微信网页开发之网页授权获取用户信息
- 微信公众号-获取用户信息(网页授权获取)
- PHP---微信OAuth2.0网页授权获取用户信息
- PHP+TP框架实现微信网页授权,获取用户信息
- 微信公众号获取用户信息-网页授权
- 微信开发之网页授权获取用户信息
- PHP+TP框架实现微信网页授权,获取用户信息
- Spring Boot 微信-网页授权获取用户信息
- 微信授权获取用户信息
- 微信网页授权,获取微信code,获取access_tocken,获取用户信息
- 网页授权获取用户信息
- 编译原理--引论
- ionic瀑布流
- 有关Html中<a>、<link>和<script>标签中相对路径与绝对路径的问题总结
- eclipse launch failed.binary not found
- 蓝桥杯:龟兔赛跑预测
- Qrcode生成二维码链接地址,网页授权获取微信用户信息
- android全屏与非全屏切换时Toolbar的显示,仿微信漂流瓶效果
- Git本地多用户配置
- 关于SpringMVC 的国际化操作
- Automapper使用
- php二维码生成
- Win7 安装SQL 2014各版本均提示“0x84B10001”错误
- Linux编译libcurl库
- 如何制作直三棱柱侧面展开图