0

我有一个带有 rss 源的 iOS 应用程序,它有 iOS 推送通知服务,推送通知适用于某些设备(以前的设备),但新的或最后的设备根本不会收到这个应用程序的推送通知。我认为错误在我的 php 脚本中,但我不知道如何解决它,与我的应用程序连接的网站的主机是 BlueHost.com。

-错误日志是:

[08-Aug-2013 11:00:14 America/Denver] PHP Warning: stream_socket_client(): unable to connect to ssl://gateway.push.apple.com:2195 (Unknown error) in /home3/basiphon/public_html/Push.php on line 56 [08-Aug-2013 11:15:24 America/Denver] PHP Warning: stream_socket_client(): SSL: crypto enabling timeout in /home3/basiphon/public_html/Push.php on line 56 [08-Aug-2013 11:15:24 America/Denver] PHP Warning: stream_socket_client(): Failed to enable crypto in /home3/basiphon/public_html/Push.php on line 56 [08-Aug-2013 11:15:24 America/Denver] PHP Warning: stream_socket_client(): unable to connect to ssl://gateway.push.apple.com:2195 (Unknown error) in /home3/basiphon/public_html/Push.php on line 56 [08-Aug-2013 11:30:33 America/Denver] PHP Warning: stream_socket_client(): unable to connect to ssl://gateway.push.apple.com:2195 (Connection timed out) in /home3/basiphon/public_html/Push.php on line 56 [08-Aug-2013 11:46:39 America/Denver] PHP Warning: stream_socket_client(): unable to connect to ssl://gateway.push.apple.com:2195 (Connection timed out) in /home3/basiphon/public_html/Push.php on line 56

-我的 PHP 脚本

    // Open a connection to the APNS server

    $fp = stream_socket_client(
        $url, $err,
        $errstr, 2, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
    if (!$fp)
        exit("Failed to connect: $err $errstr" . PHP_EOL);

    echo 'Connected to APNS' . PHP_EOL;
    // Build the binary notification
    $msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;

    // Send it to the server
    $result = fwrite($fp, $msg, strlen($msg));

    if (!$result)
        echo 'Message not delivered' . PHP_EOL;
    else
    {
        echo 'Message successfully delivered111' . PHP_EOL;
        $query_update="update wp_apns_messages set status='delivered',delivery=NOW() where pid='$pid'";
        $res_update=mysql_query($query_update) or die(mysql_error());
    }

    // Close the connection to the server
    fclose($fp);
}

//echo "***"; ?> </body> </html> </i>

4

0 回答 0