master
ELF 5 years ago
parent 1c8f8c52b4
commit f27fc012d9

@ -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 . '&timestamp=' . $time . '&url=' . $url;
$sign = sha1($signStr);

Loading…
Cancel
Save