<?php declare(strict_types=1); namespace App\Controller\Home; use App\Controller\AbstractController; use App\Model\User; use App\Exception\BusinessException; class AppletController extends BaseController { //小程序用户登录 public function login() { $code = $this->request->input('code'); $appid = $this->appInfo->config['appid']; $secret = $this->appInfo->config['appsecret']; $url = 'https://api.weixin.qq.com/sns/jscode2session?appid='.$appid.'&secret='.$secret.'&js_code='.$code.'&grant_type=authorization_code'; $info = file_get_contents($url); $info = json_decode($info); if(isset($info->errcode)){ throw new BusinessException($info->errcode, $info->errmsg); }else{ $userInfo = User::query() ->where('openid', $info
hyperf 小程序用户登录,授权
最新推荐文章于 2023-05-16 15:58:25 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)