From f27fc012d94cba55d99752e648c82ba19caf7cf4 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Tue, 1 Oct 2019 01:27:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Home/Controller/HomeController.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Application/Home/Controller/HomeController.class.php b/Application/Home/Controller/HomeController.class.php index b41ee879c..1274ac153 100644 --- a/Application/Home/Controller/HomeController.class.php +++ b/Application/Home/Controller/HomeController.class.php @@ -63,11 +63,13 @@ class HomeController extends Controller } $isExpired = false; + $ticket = ''; if ($ticketData) { $isExpired = time() > $ticketData['expired_at'] ? true : false; + $time = $ticketData['time']; + $ticket = $ticketData['ticket']; } - $ticket = ''; if (!$ticketData || $isExpired) { $ticket = $ticketData['ticket']; $result = file_get_contents($tokenUrl); @@ -90,12 +92,12 @@ class HomeController extends Controller ]); } $ticket = $result['ticket']; + file_put_contents(RUNTIME_PATH . 'Data/wechat_ticket', json_encode(['ticket' => $ticket, 'expired_at' => time() + 3600])); } $randStr = 'aaabbbxeclsx'; $time = time(); - $signStr = 'jsapi_ticket=' . $ticket . '&noncestr=' . $randStr . '×tamp=' . $time . '&url=' . $url; $sign = sha1($signStr);