Search code examples
web-servicesios6passbook

How to respond for getting pass task


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

Solution

  • 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.

    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.