views:

168

answers:

0

Im working with the apple push notification service, and i notice that some php apns code i found is using stream_socket_client. My host doesnt support this, but it does support curl. Ive read that curl can do SSL connections like the code uses, but im wondering if [a] anyone has experience in doing specifically this, and [b] the interswitchabilityness(<-nice) of stream_socket_client and curl

Here is the code in question:

$streamContext = stream_context_create();
stream_context_set_option($streamContext, 'ssl', 'local_cert', $sslPem);
stream_context_set_option($streamContext, 'ssl', 'passphrase', $passPhrase);
//stream_context_set_option($streamContext, 'ssl', 'verify_peer', false);

$apnsConnection = stream_socket_client('ssl://'.$apnsHost.':'.$apnsPort, $error, $errorString, 60, STREAM_CLIENT_CONNECT, $streamContext);

if($apnsConnection == false)
{
  print "Failed to connect {$error} {$errorString}\n";
}