Push Notification from Apple not working at all

VIVEKS

Bit poster
Hey,

I am trying to get push notification from Apple through a php page, in which i have set the .pem file (it is in the same path where the php file calling the pem file is situated) , but when i run the page in browser it shows following warnings:

Warning: stream_socket_client() [function.stream-socket-client]: Unable to set local cert chain file `vivek.pem'; Check that your cafile/capath settings include details of your certificate and its issuer in /var/www/vhosts/ipartyapps.com/httpdocs/webservices/testPush.php on line 12

Warning: stream_socket_client() [function.stream-socket-client]: failed to create an SSL handle in /var/www/vhosts/ipartyapps.com/httpdocs/webservices/testPush.php on line 12

Warning: stream_socket_client() [function.stream-socket-client]: Failed to enable crypto in /var/www/vhosts/ipartyapps.com/httpdocs/webservices/testPush.php on line 12

Warning: stream_socket_client() [function.stream-socket-client]: unable to connect to ssl://gateway.push.apple.com:2195 (Unknown error) in /var/www/vhosts/ipartyapps.com/httpdocs/webservices/testPush.php on line 12
Failed to connect 0

Both the php & .pem files are present in "/var/www/vhosts/ipartyapps.com/httpdocs/webservices" folder , previously i was getting push notification and probably no changes have been made in the files, now i ain't getting push notification.

php file

<?php
$deviceToken = '3147e8fc%202094a1a9%20f4999dfe%208a4e8af2%2053fb8cfa%20726530a2%20e8a530f5%2095c1375d';
$message = 'Skiparty push test';
$badge = 1;
$sound ='pig';
$body = array();
$body['aps'] = array('alert' => $message);
$body['aps']['badge'] = $badge;
$body['aps']['sound'] = $sound;
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'vivek.pem');
$fp = stream_socket_client('ssl://gateway.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx);
if(!$fp) {
print "Failed to connect $err $errstr\n";
return;
}
else {
print "<br>Connection OK\n";
}
$payload = json_encode($body);
$msg = chr(0).pack("n",32).pack('H*', str_replace(' ','',$deviceToken)).pack("n",strlen($payload)).$payload;
print "sending message :" . $payload . "\n";
fwrite($fp, $msg);
fclose($fp);
?>

Am i missing something , can you help me out ?
 
Back
Top