我使用此代码推送:
push("xxxx", 3);
function push($deviceToken, $badge) {
$message = "C'è il vento ideale!!";
$sound = "default";
// Construct the notification payload
$body = array();
$body['aps'] = array(
"alert" => $message
);
if ($badge) {
$body['aps']['badge'] = $badge;
}
if ($sound) {
$body['aps']['sound'] = $sound;
}
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'apns-dev.pem');
$fp = stream_socket_client("ssl://gateway.sandbox.push.apple.com:2195", $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx);
if (!$fp) {
print "Failed to connect $err $errstrn";
return;
} else {
print "Connection OK\n";
}
$payload = json_encode($body);
$msg = chr(0) . pack('n', 32) . pack('H*', str_replace(' ', '', $deviceToken)) . pack('n', strlen($payload)) . $payload;
print "sending message :" . $payload . "\n";
fwrite($fp, $msg);
fclose($fp);
}
但这是错误:
警告:stream_socket_client()[function.stream-socket-client]:SSL操作失败,代码为1. OpenSSL错误消息:错误:14094414:SSL例程:SSL3_READ_BYTES:sslv3警报证书在/xxxx/notify.php中被撤销第75行
警告:stream_socket_client()[function.stream-socket-client]:无法在第75行的/xxxx/notify.php中启用加密
警告:stream_socket_client()[function.stream-socket-client]:无法连接到/xxxxx/notify.php上的ssl://gateway.sandbox.push.apple.com:2196(未知错误) 75 无法连接0
答案 0 :(得分:2)
信息明确:certificate revoked
您的证书无效,证书已过期或您已点击Apple门户中的“撤销”证书。
您可以为此appId生成新证书,并将其安装在您的服务器上。