diff --git a/src/Wx/Mini.php b/src/Wx/Mini.php index 2470880..671f43e 100644 --- a/src/Wx/Mini.php +++ b/src/Wx/Mini.php @@ -72,11 +72,11 @@ public function get($code) $response = $this->rawBody($code); // 检查session key - $sessionKey = $response['session_key'] ?? ''; - if (strlen($sessionKey) != 20) { - throw new Exception('sesskon_key错误: ' . $sessionKey, 401900); + $sessionKey = $response['session_key']; + if (empty($sessionKey)) { + throw new Exception('sesskon_key获取失败', 401900); } - $decodeKey = base64_decode($response['session_key']); + $decodeKey = base64_decode($sessionKey); // 获取加密结果 $result = openssl_decrypt($decodeEd, 'AES-128-CBC', $decodeKey, 1, $decodeIv); @@ -92,7 +92,7 @@ public function get($code) 'nickName' => $data['nickName'], 'sex' => $data['gender'], 'avatarUrl' => $data['avatarUrl'], - 'sessionKey' => $response['session_key'], + 'sessionKey' => $sessionKey, ]; }