我正在尝试为苹果设备做一个通知系统,但是当我尝试在服务器上运行它时,我遇到以下错误:
警告:stream_socket_client():SSL:第30行/home/empresa/public_html/simplepush/push.php中的同行重置连接
警告:stream_socket_client():无法在第30行的/ home/empresa /public_html/push/push.php中启用加密
警告:stream_socket_client():无法连接到第30行的/ home/empresa /public_html/push/push.php中的ssl://gateway.sandbox.push.apple.com:2195(未知错误)无法连接:0
我的代码是这样的:
<?php
ini_set('display_errors','On');
error_reporting(E_ALL);
$deviceToken= 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$passphrase = ' ';
$message = 'my first notification';
////////////////////////////////////////////////////////////////////////////////
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
// Open a connection to the APNS server
$fp = stream_socket_client(
'ssl://gateway.sandbox.push.apple.com:2195', $err,
$errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
if (!$fp)
exit("Failed to connect: $err $errstr" . PHP_EOL);
echo 'Connected to APNS' . PHP_EOL;
// Create the payload body
$body['aps'] = array(
'alert' => $message,
'sound' => …Run Code Online (Sandbox Code Playgroud)