请问pc端网站如何实现微信扫码一键登录?
网友回复
1、先登录微信开放平台,没有账号就申请一个,地址:https://open.weixin.qq.com/
2、点击管理工具-》创建网站应用

3、填写基本信息及网站信息

4、等待审核成功后还要绑定公众号到认证的公众号上。
5、我们来看代码怎么写,我们以php为例
<?php
class wxlogin
{
var $appid = "sx23213123123123";
var $appsecret = "123124324esfdsfdsf23434324234";
//构造函数,获取Access Token
public function __construct($appid = NULL, $appsecret = NULL) {
//扫码登录不需要该Access Token, 语义理解需要
//1. 本地写入,防止token过期
$res = @file_get_contents('access_token.json');
$result = json_decode($res, true);
$this->expires_time = $result["expires_time"];
$this->access_token = $result["access_token"];
if (time() > ($this->expires_time + 3600)) {
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $this->appid . "&secret=" . $this->appsecret;
$res = $this->http_request($url);
$result = json_decode($res, true);
$this->access_token = $result["access_token"];
$this->expires_time = time();
file_put_contents('test/access_token.json', '{"access_token": "' . $this->access_token . '", "expires_time": ' . $this->expires_time . '}');
}
}
//生成扫码登录的URL,
public function qrconnect($redirect_url, $scope, $state = NULL) {
$url = "https://open.weixin.qq.com/connect/qrconnect?appid=" . $this->appid . "&redirect_uri=" . urlencode($redirect_url) . "&response_type=code&scope=" . $scope . "&state=" . $state . "#wechat_redirect";
return $url;
}
//生成OAuth2的Access Token
public function oauth2_access_token($code) {
$url = "https://api.weixin.qq.com/sns/oau...点击查看剩余70%
seedance2如何通过2张不同角度平视图来识别场景进行人物定位?
有没有免费的浏览器中离线运行的语音识别ai模型?
微信小程序个人版不交钱认证就不让你用二维码,报错"errcode":85411?
美丽国为啥要限制ai发展?
seedance2如何参考白模视频使用真实场景和人物生成新视频?
如何设定小孩看电视的时候每隔10分钟弹出一个题目,答对才能继续,答错继续下一题?
直播数字人根据公屏互动评论实时做出不用动作技术是什么?
未来ai文本大模型根据剧本直接生成像素风或三维白模或灰模粗糙场景动画html给视频大模型参考站位与运镜?
浏览器中如何将epub电子书转成txt文本格式?
有没有开源的工具直接完整下载番茄等平台的任意小说内容?


