我按照这个问题使用了 APNS 反馈服务。这是我请求反馈服务器的代码;
function send_feedback_request() {
//connect to the APNS feedback servers
//make sure you're using the right dev/production server & cert combo!
$stream_context = stream_context_create();
stream_context_set_option($stream_context, 'ssl', 'local_cert', 'my_production_cerficate.pem');
$apns = stream_socket_client('ssl://feedback.push.apple.com:2196', $errcode, $errstr, 60, STREAM_CLIENT_CONNECT, $stream_context);
if(!$apns) {
die("ERROR $errcode: $errstr\n");
}
$feedback_tokens = array();
//and read the data on the connection:
while(!feof($apns)) {
$data = fread($apns, 38);
if(strlen($data)) {
$feedback_tokens[] = unpack("N1timestamp/n1length/H*devtoken", $data);
}
}
fclose($apns);
return $feedback_tokens;
}
当我使用此功能时,它会报告以下错误;
Warning: stream_socket_client() [function.stream-socket-client]: Unable to set private key file /my_directories/my_production_cerficate.pem in /my_directories/apnsfeedback.php on line 7
Warning: stream_socket_client() [function.stream-socket-client]: failed to create an SSL handle in /my_directories/apnsfeedback.php on line 7
Warning: stream_socket_client() [function.stream-socket-client]: Failed to enable crypto in /my_directories/apnsfeedback.php on line 7
Warning: stream_socket_client() [function.stream-socket-client]: unable to connect to ssl://feedback.push.apple.com:2196 (Unknown error) in /my_directories/apnsfeedback.php on line 7
我正在使用我用于发送推送通知消息的生产证书 (.pem),它是有效的 + 工作。所以无效的证书不是这里的问题。我在这里做错了什么?