脚本宝典收集整理的这篇文章主要介绍了php – ios Push Notification无法在服务器上运行,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我测试过:
telnet gateway.sandBox.push.apple.COM 2195
这是工作…
root@server ~ # telnet gateway.sandBox.push.apple.com 2195 Trying 17.149.34.54... Connected to gateway.sandBox.push.apple.com. Escape character is '^]'.
但是,当我从我的PHP脚本测试时,它返回:
有什么建议?
$ctx = stream_context_create(); stream_context_set_option($ctx,'ssl','local_cert',"path/to/certificate"); $fp = stream_socket_client("ssl://gateway.push.apple.com:2195",$error,$errorString,100,(STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT),$ctx);
$device = 'sDFsdfsfsdffsd'; $payload['aps'] = array('alert' => 'Hello I am testing the server code ....','badge' => 1,'sound' => 'default'); $payload = json_encode($payload); $options = array('ssl' => array( 'local_cert' =>'ck.pem','passphrase' => 'abc123' )); $streamContext = stream_context_create(); stream_context_set_option($streamContext,$options); $apns = stream_socket_client('ssl://gateway.sandBox.push.apple.com:2195',60,STREAM_CLIENT_CONNECT,$streamContext); $apnsMessage = chr(0) . chr(0) . chr(32) . pack('H*',str_replace(' ','',$device)) . chr(0) . chr(strlen($payload)) . $payload; fwrITe($apns,$apnsMessage); fclose($apns);
仅检查pem文件路径,并且端口已打开.
以上是脚本宝典为你收集整理的php – ios Push Notification无法在服务器上运行全部内容,希望文章能够帮你解决php – ios Push Notification无法在服务器上运行所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。