php - unable to connect to APNS (connection time out) -


i had succeeded earlier on sending push notification iphone using raywenderlich's excellent tutorial here http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1 , running php script using mac terminal, however, trying achieve same thing have push.php script uploaded server , run script every 5 min via cron job error now:

stream_socket_client(): unable connect ssl://gateway.sandbox.push.apple.com:2195 (connection timed out)

like said before working fine earlier when running script through terminal. think problem php script server cannot access push certificates. how give script access them? please help!

heres php script if helps:

<?php   // assign data variables $devicetoken = "e39ffc6b98f649f127d07d2d881bc9faa621a3c5d59f9647e64f6452fc37af6c"; $passphrase = "9q3n6k80"; $sound = ''; $blank = "";  $ctx = stream_context_create(); stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck.pem'); stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);  // open connection 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 connect: $err $errstr" . php_eol);  echo 'connected apns' . php_eol;   // create payload body $body['aps'] = array(     'alert' => "mic check",     'sound' => 'default'     );  // encode payload json $payload = json_encode($body);  // build binary notification $msg = chr(0) . pack('n', 32) . pack('h*', $devicetoken) . pack('n', strlen($payload)) . $payload;  // send server $result = fwrite($fp, $msg, strlen($msg));  if (!$result)     echo 'message not delivered' . php_eol; else     echo 'message succesfully delivered' . php_eol;  // close connection server fclose($fp);  

thank you!

edit: im using file manager in bluehost upload files


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -