我正在努力工作,並在我的服務器上啓用openssl,但問題依然存在。如果運行MAc書,它會有什麼區別嗎?如果在那裏完成,請回復。APNS錯誤警告:stream_socket_client()錯誤
我的代碼:
<?php
$deviceToken = 'my device key'; // not putting in for security
$payload['aps'] = array('alert' => 'This is the alert text', 'badge' => 1, 'sound' => 'default');
$payload = json_encode($payload);
$apnsHost = 'gateway.sandbox.push.apple.com';
$apnsPort = 2195;
$apnsCert = 'apns-dev.pem';
$streamContext = stream_context_create();
stream_context_set_option($streamContext, 'ssl', 'local_cert', $apnsCert);
$apns = stream_socket_client('ssl://' . $apnsHost . ':' . $apnsPort, $error, $errorString, 2, STREAM_CLIENT_CONNECT, $streamContext);
$apnsMessage = chr(0) . chr(0) . chr(32) . pack('H*', str_replace(' ', '', $deviceToken)) . chr(0) . chr(strlen($payload)) . $payload;
fwrite($apns, $apnsMessage);
socket_close($apns);
fclose($apns);
?>
錯誤:
Warning: stream_socket_client() [function.stream-socket-client]: SSL operation failed with code 1. OpenSSL Error messages: error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure in F:\xampp\htdocs\apns\apns.php on line 24
Warning: stream_socket_client() [function.stream-socket-client]: Failed to enable crypto in F:\xampp\htdocs\apns\apns.php on line 24
Warning: stream_socket_client() [function.stream-socket-client]: unable to connect to ssl://gateway.sandbox.push.apple.com:2195 (Unknown error) in F:\xampp\htdocs\apns\apns.php on line 24
請後,如果有任何的想法。
謝謝
問題仍然存在:( – Jarnail 2011-07-05 10:58:49