From fbf5d34a191dcb7b67be9762fb7978da341fe2c9 Mon Sep 17 00:00:00 2001 From: Dai Date: Fri, 9 Aug 2024 17:34:51 +0800 Subject: [PATCH] =?UTF-8?q?code=20=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/WechatSubscriptController.php | 4 ++-- app/common/service/StudentService.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/api/controller/WechatSubscriptController.php b/app/api/controller/WechatSubscriptController.php index a1671d5..8d54f29 100644 --- a/app/api/controller/WechatSubscriptController.php +++ b/app/api/controller/WechatSubscriptController.php @@ -76,14 +76,14 @@ class WechatSubscriptController extends BaseController * @return array|mixed|void * @throws \GuzzleHttp\Exception\GuzzleException */ - public static function getUserInfo($access_token) + public static function getUserInfo($openid, $access_token) { try { $client = new Client(['base_uri' => self::BASE_URI]); $response = $client->request('get', 'sns/userinfo', [ 'query' => [ 'access_token' => $access_token, - 'openid' => getenv('APP_ID'), + 'openid' => $openid, 'lang' => 'zh_CN', ] ]); diff --git a/app/common/service/StudentService.php b/app/common/service/StudentService.php index 32d4a55..370c575 100644 --- a/app/common/service/StudentService.php +++ b/app/common/service/StudentService.php @@ -133,7 +133,7 @@ class StudentService throw new Exception('获取信息失败'); } - $user_info = WechatSubscriptController::getUserInfo($access_token['access_token']); + $user_info = WechatSubscriptController::getUserInfo($access_token['openid'], $access_token['access_token']); if(!empty((array)$request->student)){ $student = Student::where(['id' => $request->student->id])->findOrEmpty();