iphone - Push notification in PHP -


I get this error after trying to execute my PHP script to send push notifications to my iPhone.

> I have tried everything and nothing works; I believe that it means that my ck.pem is wrong but I am not sure if Its key.pem or cert.pem is incorrect

please help

script

  // This is a duplicate of this Device ID: $ deviceToken = '9870h8v088bj29u080af894jj67klfgcv9mmm79k8e4l23456h908743n093e359'; // fake password: $ passphrase = '123456'; // Put your alert message here: $ message = 'new message'; //////////////////////////////////////////////// ////////////////////////// $ ctx = stream_context_create (); Stream_context_set_option ($ ctx, 'ssl', 'local_cert', 'ck.pem'); Stream_context_set_option ($ ctx, 'ssl', 'passphrase', $ passphrase); // Open the connection to the APNS server $ fp = stream_socket_client ('SSL: //gateway.sandbox.push.apple.com: 2195', $$ err, $ errstr, 60, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT, $ ctx); If (! $ Fp) exit ("Failed to connect: $ err $ errstr". PHP_EOL); 'Connect to APNS' echo PHP_EOL; // Payload body $ body ['APS'] = array ('warning' => $ message, 'sound' = & gt; 'default', 'badge' = & gt; '1'); // Encrypt payload as JSON $ payload = json_encode ($ body); // Create binary notifications $ msg = chr (0) pack ('n', 32) pack ('H *', $ deviceToken). Pack ('n', strollon ($ payload)). $ Payload; // Send it to server $ result = fwrite ($ fp, $ msg, strlen ($ msg)); If the 'message was not sent' (! $ Result) echo PHP_EOL; Else 'message successfully delivered' echo PHP_EOL; // Close the server fclose ($ fp) connection; ? & Gt; Warning: stream_socket_client (): Failed with SSL operation code 1. OpenSSL error message: Error: 140 9 4416: SSL routine: SSL3_READ_BYTES: SSLv3 warning certificate in unknown / users / daveking / desktop / application certificate / on-line 21 warning simplepush .php: stream_socket_client (): in / on users / daveking / desktop / application certificate / simplepush.php failed to enable crypto on line 21 Warning: stream_socket_client (): //gateway.sandbox.push.apple.com: connect ssl Unable to book line 21 2195 (unknown error) to connect / users / daveking / desktop / application certificate / simplepush.php failed: 0    

What exactly have you tried?

This is a good tutorial for preparation of certificates, which can be php scripts etc.

Comments