fai*_*sal 2 iphone apple-push-notifications
要将我的服务器与APN服务器连接,请使用以下代码.
// coonecting the apn server
$apnsHost = 'gateway.sandbox.push.apple.com';
$apnsPort = 2195;
$apnsCert = 'apns-dev.pem';
$streamContext = stream_context_create();
stream_context_set_option($streamContext, 'ssl', 'local_cert', $apnsCert);
$apns = stream_socket_client('ssl://' . $apnsHost . ':' . $apnsPort, $errorNo, $errorString, 2, STREAM_CLIENT_CONNECT, $streamContext);
Run Code Online (Sandbox Code Playgroud)
但我无法连接,我打印$ errorNo和$ errorString输出是:错误:连接超时errorNo:110
但我也在errorLog中收到以下警告:
无法连接到第35行/home/riseupla/public_html/applications/apn/apn.php中的ssl://gateway.sandbox.push.apple.com:2195(连接超时)
我该怎么办?
注意:我可以通过我的mac项目发送推送通知(使用push me baby项目).但我的PHP项目无法连接.
你没有说你是否从与Mac不同的机器上运行php,但是如果你为你的php站点使用托管服务,那么可能是ISP已经阻止了端口2195(和2196).
尝试在运行Mac项目时使用的同一台计算机上运行php,看看这是否有帮助.如果是这种情况,那么您的ISP很可能会阻止端口,您将不得不找到不同的ISP或让它们打开端口.
克劳斯