我有一个带有RSS推送的iOS应用,它有iOS推送通知服务,推送通知适用于某些设备(以前的设备),但新设备或最后设备根本没有收到此应用的推送通知。我认为错误是在我的PHP脚本中,但我不知道如何解决它,我的网站主机连接我的应用程序是BlueHost.com。
- 错误日志是:
[08-Aug-2013 11:00:14 America/Denver] PHP Warning: stream_socket_client(): unable to connect to ssl://gateway.push.apple.com:2195 (Unknown error) in /home3/basiphon/public_html/Push.php on line 56
[08-Aug-2013 11:15:24 America/Denver] PHP Warning: stream_socket_client(): SSL: crypto enabling timeout in /home3/basiphon/public_html/Push.php on line 56
[08-Aug-2013 11:15:24 America/Denver] PHP Warning: stream_socket_client(): Failed to enable crypto in /home3/basiphon/public_html/Push.php on line 56
[08-Aug-2013 11:15:24 America/Denver] PHP Warning: stream_socket_client(): unable to connect to ssl://gateway.push.apple.com:2195 (Unknown error) in /home3/basiphon/public_html/Push.php on line 56
[08-Aug-2013 11:30:33 America/Denver] PHP Warning: stream_socket_client(): unable to connect to ssl://gateway.push.apple.com:2195 (Connection timed out) in /home3/basiphon/public_html/Push.php on line 56
[08-Aug-2013 11:46:39 America/Denver] PHP Warning: stream_socket_client(): unable to connect to ssl://gateway.push.apple.com:2195 (Connection timed out) in /home3/basiphon/public_html/Push.php on line 56
- 我的PHP脚本
// Open a connection to the APNS server
$fp = stream_socket_client(
$url, $err,
$errstr, 2, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
if (!$fp)
exit("Failed to connect: $err $errstr" . PHP_EOL);
echo 'Connected to APNS' . PHP_EOL;
// Build the binary notification
$msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;
// Send it to the server
$result = fwrite($fp, $msg, strlen($msg));
if (!$result)
echo 'Message not delivered' . PHP_EOL;
else
{
echo 'Message successfully delivered111' . PHP_EOL;
$query_update="update wp_apns_messages set status='delivered',delivery=NOW() where pid='$pid'";
$res_update=mysql_query($query_update) or die(mysql_error());
}
// Close the connection to the server
fclose($fp);
}
//echo "***";
?>
</body>
</html> </i>