Не удалось подключиться при отправке APNS

Я использую php, чтобы отправить сообщение, но оно показывает это сообщение. Должен ли я что-то путать на apache или iptable

Ошибка:-

Failed to connect: 0 php_network_getaddresses: getaddrinfo failed:
Name or service not known

Код:-

<?php
$device_tokens_array=array();
array_push($device_tokens_array,'8142804172256bd271efba1122d6560f8304e0b7a90a578b0bff138917d233c4');
array_push($device_tokens_array,'a80c93c67bef026be9affe03689288c08eb1c44f9b6bb5c3d7cc9eb9f9fbf506');// Put your private key's passphrase here:
$passphrase = 'xxxx';

// Put your alert message here:
$message = 'Hello world';

////////////////////////////////////////////////////////////////////////////////

$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);

// Open a connection to the APNS server
$fp = stream_socket_client(
'ssl://gateway.push.apple.com:2195', $err,
$errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);

if (!$fp)
exit("Failed to connect: $err $errstr " . PHP_EOL);

echo 'Connected to APNS' . PHP_EOL;

// Create the payload body
$body['aps'] = array(
'alert' => $message,
'sound' => 'default'
);

$payload = json_encode($body);

for($i=0; $i<count($device_tokens_array); $i++)
{
$msg = chr(0) . chr(0) . chr(32) . pack('H*', str_replace(' ', '', $device_tokens_array[$i])) . chr(0) . chr(strlen($payload)) . $payload;
$result = fwrite($fp, $msg, strlen($msg));
if (!$result)
echo '<br>Message not delivered' . PHP_EOL;
else
echo '<br>Message successfully delivered' . PHP_EOL;
}

// Send it to the server// Put your device token here (without spaces):// Close the connection to the server
fclose($fp);

?>

2

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector