小编pcd*_*cdl的帖子

PHP - 通过http代理的https流

我试图通过HTTPS获取流的内容,但我必须通过HTTP代理.我不想使用cURL,而是使用fopencontext参数.

问题是,我无法通过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一起使用,必须有一种方法使它适用于上下文.我试图将上下文选项更改为一堆不同的值,但没有运气.

任何帮助将不胜感激 !

谢谢.

php https proxy curl stream

1
推荐指数
1
解决办法
7649
查看次数

标签 统计

curl ×1

https ×1

php ×1

proxy ×1

stream ×1