我试图通过HTTPS获取流的内容,但我必须通过HTTP代理.我不想使用cURL,而是使用fopen和context参数.
问题是,我无法通过HTTPS工作(HTTP工作正常).
这DOES NOT工作:
$stream = stream_context_create(Array("http" => Array("method" => "GET",
"timeout" => 20,
"proxy" => "tcp://my-proxy:3128",
'request_fulluri' => True
)));
echo file_get_contents('https://my-stream', false, $context);
Run Code Online (Sandbox Code Playgroud)
这DOES作品(卷曲):
$url = 'https://my-stream';
$proxy = 'my-proxy:3128';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
$curl_scraped_page = curl_exec($ch);
curl_close($ch);
echo $curl_scraped_page;
Run Code Online (Sandbox Code Playgroud)
有人知道第一段代码有什么问题吗?如果它与cURL一起使用,必须有一种方法使它适用于上下文.我试图将上下文选项更改为一堆不同的值,但没有运气.
任何帮助将不胜感激 !
谢谢.