phpcms实现微信登录的方法:1、在根目录新建“wechat.php”;2、在“\phpcms\modules\member\index.php”下增加“public function wechat() {...}”;3、在“foreground.class.php”文件中通过wechat函数判断用户是否登录即可。
本教程操作环境:Windows10系统、phpcms v9版,DELL G3电脑
phpcms怎么实现微信登陆?
phpcms实现微信登陆(无需注册,直接存入)
思路:回调参数,直接register (代码不够规范,自己整理)
在根目录新建wechat.php
访问: http://www.xxxxxx.cn/wechat.php
注意回调地址
phpcms实现微信登陆(无需注册,直接存入)
wechat.php
<?php if(!empty( $_GET@['code']) && !empty( $_GET@['state'])){ $code = $_GET@['code']; $state = $_GET@['state']; $url = "http://www.xxxxxx.cn/index.php?m=member&c=index&a=wechat&code=$code&state=$state"; header('location:'.$url); exit; } $appid = 'wx5a3878682fa32bd5'; $url = "https://open.weixin.qq.com/connect/qrconnect?appid=$appid&redirect_uri=http://www.xxxxxx.cn/wechat.php&response_type=code&scope=snsapi_login&state=1&connect_redirect=1#wechat_redirect"; header('location:'.$url); ?>登录后复制
本文地址:http://gzyunji.cn