如何回应获得传递任务 [英] How to respond for getting pass task

查看:133
本文介绍了如何回应获得传递任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个用于更新通行证的Web服务器。我通过打开或关闭切换来测试更新以进行自动更新。这是我从控制台得到的:

4月8日13:19:47 CamMobs-iPod4传递[21]<警告>:获取传递任务(传递类型pass.cam -mob.passbookpasstest,序列号0001,if-modified-since(null);与web服务url http://192.168.1.202:8888/passesWebserver/)遇到错误:服务器响应格式错误(缺少响应数据)
这是我使用的代码:

I am doing a web server for updating a pass. I test for updating by turn the toggle on or off for automatic updates. This is what I get from console:
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) This is the code I use:

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


推荐答案

您正在选择从您的注册表中的所有内容(*)到 $ row ,然后处理 $ row 就好像它是一个MySQL行当它实际上是一个MySQL结果。

You are selecting everything (*) from your registration table into $row, but then processing $row as if it is a MySQL row when it is actually a MySQL result.

因此你的if语句没有触发,所以你的代码没有发回内容而不是传票预期的.pkpass包。

Therefore your if statement is not triggering and so your code is sending back no content instead of the .pkpass bundle that passbook is expecting.

这篇关于如何回应获得传递任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆