|
|
@ -63,11 +63,13 @@ class HomeController extends Controller
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$isExpired = false;
|
|
|
|
$isExpired = false;
|
|
|
|
|
|
|
|
$ticket = '';
|
|
|
|
if ($ticketData) {
|
|
|
|
if ($ticketData) {
|
|
|
|
$isExpired = time() > $ticketData['expired_at'] ? true : false;
|
|
|
|
$isExpired = time() > $ticketData['expired_at'] ? true : false;
|
|
|
|
|
|
|
|
$time = $ticketData['time'];
|
|
|
|
|
|
|
|
$ticket = $ticketData['ticket'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$ticket = '';
|
|
|
|
|
|
|
|
if (!$ticketData || $isExpired) {
|
|
|
|
if (!$ticketData || $isExpired) {
|
|
|
|
$ticket = $ticketData['ticket'];
|
|
|
|
$ticket = $ticketData['ticket'];
|
|
|
|
$result = file_get_contents($tokenUrl);
|
|
|
|
$result = file_get_contents($tokenUrl);
|
|
|
@ -90,12 +92,12 @@ class HomeController extends Controller
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$ticket = $result['ticket'];
|
|
|
|
$ticket = $result['ticket'];
|
|
|
|
|
|
|
|
|
|
|
|
file_put_contents(RUNTIME_PATH . 'Data/wechat_ticket', json_encode(['ticket' => $ticket, 'expired_at' => time() + 3600]));
|
|
|
|
file_put_contents(RUNTIME_PATH . 'Data/wechat_ticket', json_encode(['ticket' => $ticket, 'expired_at' => time() + 3600]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$randStr = 'aaabbbxeclsx';
|
|
|
|
$randStr = 'aaabbbxeclsx';
|
|
|
|
$time = time();
|
|
|
|
$time = time();
|
|
|
|
|
|
|
|
|
|
|
|
$signStr = 'jsapi_ticket=' . $ticket . '&noncestr=' . $randStr . '×tamp=' . $time . '&url=' . $url;
|
|
|
|
$signStr = 'jsapi_ticket=' . $ticket . '&noncestr=' . $randStr . '×tamp=' . $time . '&url=' . $url;
|
|
|
|
$sign = sha1($signStr);
|
|
|
|
$sign = sha1($signStr);
|
|
|
|
|
|
|
|
|
|
|
|