【发布时间】:2013-04-08 13:52:45
【问题描述】:
我关注了this 使用 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),它是有效的 + 工作。所以无效的证书不是这里的问题。我在这里做错了什么?
【问题讨论】:
-
你有证书+密钥组合在那个文件中吗?您的权限是否使 Web 服务器可以读取该文件?密钥是否受密码保护?等等等等。
-
我正在通过该证书发送推送通知,与 push.php 脚本位于同一目录中。所以是的,它有证书+密钥。用于推送消息的常规 pem 文件。它受密钥保护,但我无法设置密钥,因为它会出现另一个错误,提示无法设置密码...我应该使用与常规推送通知证书不同的证书吗?
标签: php ios push-notification apple-push-notifications