From d05c98099ef030528f5baf403e6f36019239f293 Mon Sep 17 00:00:00 2001 From: Anyon Date: Thu, 19 Apr 2018 15:26:45 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=9B=B4=E6=96=B0]=E5=A2=9E=E5=8A=A0=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E5=B0=8F=E7=A8=8B=E5=BA=8F=E7=99=BB=E5=BD=95=E8=A7=A3?= =?UTF-8?q?=E7=A0=81=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Test/mini-login.php | 20 ++++++++++++++++++++ WeMini/Crypt.php | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 Test/mini-login.php diff --git a/Test/mini-login.php b/Test/mini-login.php new file mode 100644 index 0000000..2f3bab3 --- /dev/null +++ b/Test/mini-login.php @@ -0,0 +1,20 @@ + 'wx6bb7b70258da09c6', + 'appsecret' => '78b7b8d65bd67b078babf951d4342b42', +]; + +// 解码数据 +$iv = 'ltM/wT7hsAl0TijEBI4v/g=='; +$code = '013LyiTR0TwjC92QjJRR0mEsTR0LyiT3'; +$decode = 'eIoVtIC2YzLCnrwiIs1IBbXMvC0vyL8bo1IhD38fUQIRbk3lgTWa0Hdw/Ty7NTs3iu7YlqqZBti+cxd6dCfeXBUQwTO2QpbHg0WTeDAdrihsHRHm4dCWdfTx8rzDloGbNOIsKdRElIhUH5YFdiTr5AYiufUDb34cwJ4GNWLAUq4bR0dmFeVEi+3nfwe2MAjGYDl4aq719VLsHodOggK6lXZvM5wjoDyuZsK2dPqJr3/Ji30Z0mdyFq32R4uR3rtJH/h+Rj0+/QmE9QYG7Y6Z48hgPE8cpnhRQNwH49jnC/zKZ9wtDkQ/J8J3Ed2i58zcuY01v8IV+pZ8oBUKXfO5ha+APOxtBSTzyHraU/2RGo8UWtOF6h64OQZhd/UQQy362eyc/qoq8sF9JnEFRP0mRmTDJ+u9oyDhxswCu6x8V73ERWaJeEGSCyjiGpep7/DxZ6eSSBq36OB0BWBkJqsq9Q=='; +$sessionKey = 'OetNxl86B/yMpbwG6wtMEw=='; +$mini = new WeMini\Crypt($config); +echo '
';
+//print_r($mini->session($code));
+print_r($mini->decode($iv, $sessionKey, $decode));
+//print_r($mini->userInfo($code, $iv, $decode));
\ No newline at end of file
diff --git a/WeMini/Crypt.php b/WeMini/Crypt.php
index c593176..70081ed 100644
--- a/WeMini/Crypt.php
+++ b/WeMini/Crypt.php
@@ -41,7 +41,7 @@ class Crypt extends BasicWeChat
         $pc = new \WXBizDataCrypt($this->config->get('appid'), $sessionKey);
         $errCode = $pc->decryptData($encryptedData, $iv, $data);
         if ($errCode == 0) {
-            return $data;
+            return json_decode($data, true);
         }
         return false;
     }
@@ -72,7 +72,7 @@ class Crypt extends BasicWeChat
     {
         $result = $this->session($code);
         if (empty($result['session_key'])) {
-            throw new InvalidResponseException('Code换取SessionKey失败', 403);
+            throw new InvalidResponseException('Code 换取 SessionKey 失败', 403);
         }
         $userinfo = $this->decode($iv, $result['session_key'], $encryptedData);
         if (empty($userinfo)) {