title: Using push notification using Api
body: <p>I am trying to use push notification using Api and I am not getting any error message neither I am getting any response.</p>
  <p>I have checked <a href="https://stackoverflow.com/questions/3891118/apple-push-notification-service-with-php-script/17723596#17723596">Apple Push Notification Service with PHP Script</a></p>
  <p>and applied changes in my code accordingly but still not working.</p>
  <p>I am not able to get how to get <code>serverId</code> that I have to use in</p>
  <pre><code>$device = 'fbb5a9c71066794d57fee33b4005a89f1bb8941a68660fd6e91f466be1299ab6'; // My iphone deviceToken
  $payload['aps'] = array(
      'alert' =&gt; 'This is the alert text',
      'badge' =&gt; 1,
      'sound' =&gt; 'default'
  );
  
  $payload['server'] = array(
      'serverId' =&gt; 1,
      'name' =&gt; 'keyss.in'
  );
  
  $payload = json_encode($payload);
  
  $apnsCert = 'apple_push_notification_production.pem';
  
  $streamContext = stream_context_create();
  stream_context_set_option($streamContext, 'ssl', 'local_cert', $apnsCert);
  
  $apns = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $error, $errorString, 2, STREAM_CLIENT_CONNECT, $streamContext);
  
  $apnsMessage = chr(0) . chr(0) . chr(32) . pack('H*', str_replace(' ', '', $device)) . chr(0) . chr(strlen($payload)) . $payload;
  fwrite($apns, $apnsMessage);
  
  //socket_close($apns); seems to be wrong here ...
  fclose($apns);
      
  </code></pre>
  <p>Getting the errors:</p>
  <blockquote>
  <p>Warning: stream_socket_client(): unable to connect to ssl://gateway.sandbox.push.apple.com:2195 (Connection timed out)</p>
  <p>Warning: fwrite() expects parameter 1 to be resource, boolean given</p>
  <p>Warning: fclose() expects parameter 1 to be resource, boolean given</p>
  </blockquote>