我正在做一个用于更新通行证的网络服务器。我通过打开或关闭自动更新的切换来测试更新。这是我从控制台得到的:
Apr 8 13:19:47 CamMobs-iPod4 passd[21] <Warning>: Get pass task (pass type pass.cam-mob.passbookpasstest, serial number 0001, if-modified-since (null); with web service url http://192.168.1.202:8888/passesWebserver/) encountered error: Server response was malformed (Missing response data)
这是我使用的代码:
if (strtoupper($_SERVER['REQUEST_METHOD']) === "GET" && $request[3]==='passes'){
$passTypeID = $request[4];
$serial = $request[5];
$auth_key = str_replace('ApplePass ', '', $headers['Authorization']);
$querySelect = mysql_query("select * from registration");
$row = mysql_fetch_array($querySelect);
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])){
if ($passTypeID == $row['passTypeID'] && $serial ==$row['serialNo']){
$pkpass_file = '/Applications/MAMP/htdocs/passesWebserver/DigiClubCard.pkpass';
header("Pragma: no-cache");
header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
header("Content-type: application/vnd.apple.pkpass; charset=UTF-8");
header('Content-Disposition:attachment; filename="genericPass.pkpass"');
clearstatcache();
$filesize = filesize($pkpass_file);
if ($filesize)
header("Content-Length: ". $filesize);
header('Content-Transfer-Encoding: binary');
if (filemtime($pkpass_file)) {
date_default_timezone_set("UTC");
header('Last-Modified: ' . date("D, d M Y H:i:s", filemtime($pkpass_file)) . ' GMT');
}
flush();
readfile($pkpass_file);
} } }`