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();