gpt4 book ai didi

php - Apple Push Notification 在我的 godaddy 共享服务器上不起作用,连接失败 111 连接被拒绝 php 推送通知错误

转载 作者:可可西里 更新时间:2023-11-01 00:42:23 24 4
gpt4 key购买 nike

我收到一个错误,例如无法连接 111 连接拒绝使用 APNS 的 php 推送通知。它在本地服务器上运行良好,但在 GoDaddy 共享服务器上运行不正常。请查找我的 Php 代码。

$path_pem_file="http://dummy.com/uploads/app/1.pem";
// this is the pass phrase you defined when creating the key
$passphrase = '';
// this is where you can customize your notification
$payload = '{"aps":{"alert":"message","sound":"default"}}';

// start to create connection
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', $path_pem_file);
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);

$fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
// Build the binary notification
$msg = chr(0) . pack('n', 32) . pack('H*', 'Device token here..') . pack('n', strlen($payload)) . $payload;
// Send it to the server
$result = fwrite($fp, $msg, strlen($msg));

if ($fp) { fclose($fp);}

最佳答案

您需要在服务器上打开以下端 Eloquent 能使用 Apple APNs

2195
2196

据我所知,GoDaddy 不会在共享主机上为您打开此端口,您必须使用专用服务器或 VPS。

关于php - Apple Push Notification 在我的 godaddy 共享服务器上不起作用,连接失败 111 连接被拒绝 php 推送通知错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31537315/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com