我需要向IOS用户发送推送通知,并且每次出现此错误时:连接失败:0 php_network_getaddresses:getaddrinfo失败:名称解析暂时失败
$deviceToken = 'f672c26cbfb279e45c1b66d0ddb738d8043c785d5bb8dd20a72d52ae88d4a604';
// Put your private key's passphrase here:
$passphrase = 'pushchat';
$APNSCert = './IOS_PEM_File/my.pem';
$PassPhrase = "1234";
// Put your alert message here:
$message = 'Hello';
$auth = base64_encode("usr:123");
////////////////////////////////////////////////////////////////////////////////
$Options = array
(
'http' => array
(
'proxy' => 'tcp://10.0.8.23:8081',
'request_fulluri' => true,
'header' => "Proxy-Authorization: Basic $auth"
)
);
$streamContext = stream_context_create($Options);
stream_context_set_default($Options);
stream_context_set_option($streamContext, 'ssl', 'local_cert', $APNSCert);
stream_context_set_option ($streamContext, '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, $streamContext);
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'
);
// Encode the payload as JSON
$payload = json_encode($body);
// Build the binary notification
$msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;
// Send it to the server
$result = fwrite($fp, $msg, strlen($msg));
if (!$result)
{
echo 'Message not delivered' . PHP_EOL;
}
else
{
echo 'Message successfully delivered' . PHP_EOL;
}
// Close the connection to the server
fclose($fp);
我试图使用代理服务器发送,但它返回此错误。