我开始创建一些基于此的代码,用于从PHP发送推送通知.
但是现在我已经知道有一个新的API利用HTTP/2并在响应中提供反馈,我试图弄清楚我需要做些什么来获得反馈.
我无法找到任何教程或示例代码来指导我(我猜因为它是如此新的).
是否可以使用stream_socket_client()
与新提供者API连接到APNS 的方法?我如何获得反馈?我fwrite($fp, $msg, strlen($msg))
现在回来的只是一个数字.出于所有意图和目的,您可以认为我的代码与基于我的代码的SO问题中的代码相同
谢谢!
有没有办法强制PHP与另一台服务器建立HTTP2连接只是为了查看该服务器是否支持它?
我试过了:
$options = stream_context_create(array(
'http' => array(
'method' => 'GET',
'timeout' => 5,
'protocol_version' => 1.1
)
));
$res = file_get_contents($url, false, $options);
var_dump($http_response_header);
Run Code Online (Sandbox Code Playgroud)
并试过:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTP_VERSION, 3);
$response = curl_exec($ch);
var_dump($response);
curl_close($ch);
Run Code Online (Sandbox Code Playgroud)
但是如果我使用以下URL,两种方式都会给我一个HTTP1.1响应 https://www.google.com/#q=apache+2.5+http%2F2
我正在从启用HTTP/2 + SSL的域发送请求.我究竟做错了什么?