问题
When i execute the below code it is getting
Failed to connect: 0
1) My path to .pem file is correct.Below is the code which i executed. Iam completely new for this dono wats happening in the code.
I am placing the code below
$deviceToken = '44fb58e8011392a1569ddc73ff96d028b5d78739258678455a16abf4e55fa1c1';
//$deviceToken = '44fb58e8011392a1569ddc73ff96d028b5d78739258678455a16abf4e55fa1c1';
// Put your private key's passphrase here:
$passphrase = 'zFaMRvDh7vGTPqh3k+72uz0SzOh3knVZc99OPqkJ3llbYWbpQnRNAKY7TGJu7kg8';
// Put your alert message here:
$message = 'Thank you for Trying Arial 1. Do not forget to enter your feedback to earn TNB points within 10 days';
////////////////////////////////////////////////////////////////////////////////
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'http://dev.trynbuyindia.com/ck.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
// Open a 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);
回答1:
dev.trynbuyindia.com/ck.pem is this correct..???
Put your certificate in local machine same folder from where you are running php script and change its path in the script
回答2:
Use the full path where your PEM file located it may be like this supposei have keeped my PEM file in model directory then my path would be like this
stream_context_set_option($ctx, 'ssl', 'local_cert', '/var/www/abc/testws/public_html/WebService/application/models/ck.pem');
It is working for me.
来源:https://stackoverflow.com/questions/22143589/failed-to-connect-0-push-notification