From 30e9a040b4505b22052a698f62a3b59273751927 Mon Sep 17 00:00:00 2001 From: Anoxia Date: Sat, 2 Feb 2019 19:32:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Wx/Mini.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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, ]; }