智慧建站平台,千套网站模板,免费随心选!

您现在的位置: 首页>>网站教程

phpcms怎么实现微信登陆

来源: 发布时间:2023-03-09热度:1268 ℃
phpcms实现微信登录的方法:1、在根目录新建“wechat.php”;2、在“phpcmsmodulesmemberindex.php”下增加“public function wechat() {···

phpcms实现微信登录的方法:1、在根目录新建“wechat.php”;2、在“\phpcms\modules\member\index.php”下增加“public function wechat() {...}”;3、在“foreground.class.php”文件中通过wechat函数判断用户是否登录即可。

phpcms怎么实现微信登陆

本教程操作环境:Windows10系统、phpcms v9版,DELL G3电脑

phpcms怎么实现微信登陆?

phpcms实现微信登陆(无需注册,直接存入) 

思路:回调参数,直接register (代码不够规范,自己整理)

在根目录新建wechat.php 

访问: http://www.xxxxxx.cn/wechat.php

注意回调地址 

phpcms实现微信登陆(无需注册,直接存入)

wechat.php

<?php
if(!empty( $_GET@[&#39;code&#39;]) && !empty( $_GET@[&#39;state&#39;])){
    $code = $_GET@[&#39;code&#39;];
    $state = $_GET@[&#39;state&#39;];
    $url = "http://www.xxxxxx.cn/index.php?m=member&c=index&a=wechat&code=$code&state=$state";
    header(&#39;location:&#39;.$url);
    exit;
}
$appid = &#39;wx5a3878682fa32bd5&#39;;
$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(&#39;location:&#39;.$url);
?>
登录后复制

本文地址:http://yunji1.cn