Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/274.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 苹果推送通知服务_Php_Macos_Openssl_Apple Push Notifications - Fatal编程技术网

Php 苹果推送通知服务

Php 苹果推送通知服务,php,macos,openssl,apple-push-notifications,Php,Macos,Openssl,Apple Push Notifications,我尝试使用本地mac计算机运行,但出现以下错误 Warning: stream_socket_client() [function.stream-socket-client]: Unable to set private key file `/Applications/XAMPP/xamppfiles/htdocs/apns/apns-dev.pem’ in /Applications/XAMPP/xamppfiles/htdocs/apns/apns.php on line 9 Warnin

我尝试使用本地mac计算机运行,但出现以下错误

Warning: stream_socket_client() [function.stream-socket-client]: Unable to set private key file `/Applications/XAMPP/xamppfiles/htdocs/apns/apns-dev.pem’ in /Applications/XAMPP/xamppfiles/htdocs/apns/apns.php on line 9

Warning: stream_socket_client() [function.stream-socket-client]: failed to create an SSL handle in /Applications/XAMPP/xamppfiles/htdocs/apns/apns.php on line 9

Warning: stream_socket_client() [function.stream-socket-client]: Failed to enable crypto in /Applications/XAMPP/xamppfiles/htdocs/apns/apns.php on line 9

Warning: stream_socket_client() [function.stream-socket-client]: unable to connect to ssl://gateway.sandbox.push.apple.com:2195 (Unknown error) in /Applications/XAMPP/xamppfiles/htdocs/apns/apns.php on line 9

Warning: socket_close() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/apns/apns.php on line 11

Warning: fclose() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/apns/apns.php on line 12
我从其他机器上获得了PEM认证

所以我完全不知道我现在要做什么


请让我知道我需要做什么才能在localhost中运行它

我想你可能已经导出了证书,但不是苹果提供的.cer文件中的私钥

markbates的这些说明可能会有所帮助:

一旦您从 Apple为您的应用程序导出 您的密钥和apple证书如下所示: p12文件。下面是一个快速演练 关于如何做到这一点:

  • 单击Keychain Access中证书旁边的披露箭头 然后选择证书和 钥匙
  • 右键单击并选择导出2项…
  • 从下拉列表中选择p12格式,并将其命名为
    cert.p12
  • 现在将p12文件转换为pem文件:


    hi jessecurry非常感谢您的建议,它工作得很好,除了一个警告:socket\u close():提供的资源不是有效的socket资源。你能告诉我可能是什么问题吗?听起来像是php错误。您使用的是什么版本的php?您将传递什么到socket_close()?iam使用pHP版本5$apns=stream_socket_client($ssl://'.$apnsHost.:'.$apnsPort,$error,$errorString,2,stream_client_CONNECT,$streamContext);插座关闭($apns);我不是一个真正的PHP爱好者,但我认为当您使用stream\u socket\u客户端创建时,可能会使用fclose()。我认为socket\u close()与socket\u create()配合使用,不过不要太认真,我可能错了。谢谢!我使用了一种稍微不同的方法来分别转换证书和密钥,尽管在过去它可以工作,但在我需要续订时它不再工作。这个方法工作得很好,也很简单。我也有同样的问题,我可以在我本地的XAMPP服务器上运行。但是它没有在我的外部服务器上运行。嗨,Biranchi,请与您的主机提供商联系,以获得解决您问题的白名单端口
    $ openssl pkcs12 -in cert.p12 -out apple_push_notification_production.pem -nodes -clcerts