我在从Github实现存折(PHP-PKPass)时遇到了典型问题。设备注册无法正常工作。我正在使用HTTP服务(WebserviceURL),这是我的代码(Web服务):
<?php
mysql_connect("localhost","username","Password");
mysql_select_db("passesdb");
$request = explode("/", substr(@$_SERVER['REQUEST_URI'], 1));
if (isset($_SERVER['HTTP_AUTHORIZATION'])
&& strpos($_SERVER['HTTP_AUTHORIZATION'], 'ApplePass') === 0 ){
$auth_key = str_replace('ApplePass ', '', $_SERVER['HTTP_AUTHORIZATION']);
$device_id = $request[3];
$pass_id = $request[5];
$serial = $request[6];
$phpObj = @file_get_contents('php://input');
$f = json_encode($phpObj);
// Catch the JSON post and decode it
$dt = @file_get_contents('php://input');
$device_token = json_decode($dt);
$device_token1 = $device_token->pushToken;
// if (!$device_token) die('No Token Found'); // Token wasn't found
$auth_key = str_replace('ApplePass ', '', $_SERVER['HTTP_AUTHORIZATION']);
$sql = mysql_query("INSERT INTO token(name)VALUES('".$dt."')");
mysql_query($sql);
exit;
}
?>
按下“添加”按钮后我的设备记录
Jun 23 15:47:15 vairats-iPhone passd[19548] <Warning>: Registering with Apple Push Service for push topics {(
"pass.com.vaisoft.coupon"
)}
Jun 23 15:47:15 vairats-iPhone locationd[54] <Notice>: Location icon should now be in state 'Active'
Jun 23 15:47:15 vairats-iPhone MobileSafari[19527] <Warning>: Warning: Attempt to dismiss from view controller <BrowserRootViewController: 0x1f5bf890> while a presentation or dismiss is in progress!
当删除或刷新通过设备日志显示URL正在触发但是为什么注册时没有触发?
更新时设备日志如下:
Jun 23 15:51:37 vairats-iPhone locationd[54] <Notice>: Location icon should now be in state 'Inactive'
Jun 23 15:51:37 vairats-iPhone passd[19568] <Warning>: Generating GET request with URL <http:/xxx.xxx.xxx.xx/pits_demo/v1/passes/pass.com.vaisoft.coupon/test>
Jun 23 15:51:37 vairats-iPhone passd[19568] <Warning>: Request contains header field <Authorization: ApplePass 72aa48d08db9a379f147e38fb23a3901>
Jun 23 15:51:38 vairats-iPhone passd[19568] <Warning>: Get pass task (pass type pass.com.vaisoft.coupon, serial number test, if-modified-since (null); with web service url webServiceURL) got response with code 404
Jun 23 15:51:38 vairats-iPhone passd[19568] <Warning>: Get pass task (pass type pass.com.vaisoft.coupon, serial number test, if-modified-since (null); with web service url webServiceURL) encountered error: Unexpected response code 404
Jun 23 15:51:38 vairats-iPhone passd[19568] <Warning>: Generating POST request with URL <http:/xxx.xxx.xxx.xx/pits_demo/v1/log>
Jun 23 15:51:38 vairats-iPhone passd[19568] <Warning>: Request contains body dictionary {
logs = (
"[2014-06-21 14:34:17 +0530] Unregister task (for device d519e4750932a33023ef04cf2075c3f1, pass type pass.com.vaisoft.coupon, serial number test; with web service url webServiceURL) encountered error: Unexpected response code 405",
"[2014-06-21 15:34:19 +0530] Unregister task (for device d519e4750932a33023ef04cf2075c3f1, pass type pass.com.vaisoft.coupon, serial number test; with web service url webServiceURL) encountered error: Unexpected response code 405",
"[2014-06-23 15:50:24 +0530] Get pass task (pass type pass.com.vaisoft.coupon, serial number test, if-modified-since (null); with web service url webServiceURL) encountered error: Unexpected response code 404",
"[2014-06-23 15:50:35 +0530] Get pass task (pass type pass.com.vaisoft.coupon, serial number test, if-modified-since (null); with web service url webServiceURL) encountered error: Unexpected response code 404"
);
}
删除时设备日志如下:
Jun 23 15:55:27 vairats-iPhone locationd[54] <Notice>: Location icon should now be in state 'Inactive'
Jun 23 15:55:28 vairats-iPhone passd[19568] <Warning>: Generating DELETE request with URL <http:/xxx.xxx.xxx.xx/pits_demo/v1/devices/9516b180181695f4c9a5bb15a94ed270/registrations/pass.com.vaisoft.coupon/test>
Jun 23 15:55:28 vairats-iPhone passd[19568] <Warning>: Request contains header field <Authorization: ApplePass 72aa48d08db9a379f147e38fb23a3901>
Jun 23 15:55:29 vairats-iPhone passd[19568] <Warning>: Unregister task (for device 9516b180181695f4c9a5bb15a94ed270, pass type pass.com.vaisoft.coupon, serial number test; with web service url webServiceURL) got response with code 405
Jun 23 15:55:29 vairats-iPhone passd[19568] <Warning>: Unregister task (for device 9516b180181695f4c9a5bb15a94ed270, pass type pass.com.vaisoft.coupon, serial number test; with web service url webServiceURL) encountered error: Unexpected response code 405
Jun 23 15:55:29 vairats-iPhone passd[19568] <Warning>: Generating POST request with URL <http:/xxx.xxx.xxx.xx/pits_demo/v1/log>
Jun 23 15:55:29 vairats-iPhone passd[19568] <Warning>: Request contains body dictionary {
logs = (
"[2014-06-21 11:31:04 +0530] Unregister task (for device d519e4750932a33023ef04cf2075c3f1, pass type pass.com.vaisoft.coupon, serial number test; with web service url webServiceURL) encountered error: Unexpected response code
"[2014-06-21 11:44:13 +0530] Unregister task (for device d519e4750932a33023ef04cf2075c3f1, pass type pass.com.vaisoft.coupon, serial number test; with web service url webServiceURL) encountered error: Unexpected response code 405",
"[2014-06-21 11:54:15 +0530] Unregister task (for device d519e4750932a33023ef04cf2075c3f1, pass type pass.com.vaisoft.coupon, serial number test; with web service url webServiceURL) encountered error: Unexpected response code 405",
"[2014-06-21 12:04:16 +0530] Unregister task (for device d519e4750932a33023ef04cf2075c3f1, pass type pass.com.vaisoft.coupon, serial number test; with web service url webServiceURL) encountered error: Unexpected response code 405",
pass.com.vaisoft.coupon, serial number test, if-modified-since (null); with web service url webServiceURL) encountered error: Unexpected response code 404",
"[2014-06-23 15:52:31 +0530] Unregister task (for device ef4127d8aa3031223700ee2d163aca5d, pass type pass.com.vaisoft.coupon, serial number test; with web service url webServiceURL) encountered error: Unexpected response code 405",
);
}
Jun 23 15:55:29 vairats-iPhone passd[19568] <Warning>: Unregister task (for device 9516b180181695f4c9a5bb15a94ed270, pass type pass.com.vaisoft.coupon, serial number test; with web service url webServiceURL) will retry after 60 seconds
请帮帮我。