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