通过php更新存折

时间:2014-05-12 15:58:20

标签: passbook

我通过PHP创建了一个传递,并在iOS模拟器和我的iPhone上尝试过,一切正常。

现在我坚持完成任务"更新我的通行证"这里的问题是我没有将任何有效载荷送回我的服务器。

我有AlphaSSL证书。在我的服务器上运行这是Pass的JSON文件:

JSON:

{ 
    "passTypeIdentifier": "pass.com.XXXXXXX.musterkarte",
    "formatVersion": 1,
    "organizationName": "Melters Werbeagentur GmbH",
    "teamIdentifier": "XXXXXXXX",
    "serialNumber": "test",
    "backgroundColor": "rgb(240,240,240)",
    "logoText": "Hi, there!",
    "description": "testpass",
    "storeCard": {
        "secondaryFields": [
            {
                "key": "balance",
                "label": "BALANCE",
                "value": "$7.36",
                "changeMessage": "change your balance to %@"
            },
            {
                "key": "name",
                "label": "NICKNAME",
                "value": "hello"
            }

        ],
        "backFields": [
            {
                "key": "id",
                "label": "Card Number",
                "value": "test"
            }
        ]
    },
    "barcode": {
        "format": "PKBarcodeFormatPDF417",
        "message": "test",
        "messageEncoding": "iso-8859-1",
        "altText": "test"
    },
    "locations" : [
        {
            "latitude" : 51.222294,
            "longitude" : 6.792051,
        }
    ],
    "authenticationToken":"72aa48d08db9a379f147e38fb23a3901",
    "webServiceURL":"https://melters-server.com/passbook_update/"

    }

这是我的webservice index.php:     

$request = explode("/", substr(@$_SERVER['REQUEST_URI'], 1));



if (strtoupper($_SERVER['REQUEST_METHOD']) === "POST"

    && isset($_SERVER['HTTP_AUTHORIZATION'])

    && strpos($_SERVER['HTTP_AUTHORIZATION'], 'ApplePass') === 0

    && $request[2] === "devices"

    && $request[4] === "registrations") {



    $auth_key = str_replace('ApplePass ', '', $_SERVER['HTTP_AUTHORIZATION']);



    $device_id = $request[3];

    $pass_id = $request[5];

    $serial = $request[6];



    // Catch the JSON post and decode it

    $dt = @file_get_contents('php://input');

    $device_token = json_decode($dt);

    $device_token = $device_token->pushToken;

    if (!$device_token) die('No Token Found'); // Token wasn't found



    $sql="INSERT INTO token (id, token) VALUES (1, '".$device_token."')";



    mysql_query($sql,$link);

    exit;

}

?>

问题是在我向手机添加新传递后,数据库仍为空。

我访问

https://www.melters-server.com/passbook_update/version/devices/deviceLibraryIdentifier/registrations/passTypeIdentifier/serialNumber

然后我在浏览器中获得此信息:

GET 443 数组([0] => passbook_update [1] =>版本[2] =>设备[3] => deviceLibraryIdentifier [4] =>注册[5] => passTypeIdentifier [6] => serialNumber)

1 个答案:

答案 0 :(得分:0)

根据您的评论,您的webServiceURL服务器证书似乎是自签名的,或者无法验证证书链。

如果我通过this validator运行您的证书,则意味着后者。

在测试设备上的开发人员选项(设置 - >开发人员)中,启用PassKit测试下的“允许HTTP服务”并使用HTTP webServiceURL,或者仔细检查SSL证书的证书链你的服务器。