无法通过代理使用,php和curl发出https请求

时间:2013-06-28 20:56:37

标签: php curl https proxy

我们无法使用php和curl通过代理发出https请求。我们尝试从PHP发送一个简单的curl请求到https://google.com,我们收到消息'请求无法处理。代理或网关服务器收到的响应无效'。对http:/google.com的相同请求工作正常。我们还可以从curl命令行成功调用任何https url。以下是我们的卷曲请求。代理不需要登录,我们在PHP中安装了openssl。任何回复都表示赞赏。

$url='https://google.com';
$handle = curl_init();
curl_setopt($handle, CURLOPT_URL, $url);
curl_setopt($handle, CURLOPT_PROXY, 'some proxy');
curl_setopt($handle, CURLOPT_PROXYPORT, 80);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($handle, CURLOPT_VERBOSE, TRUE);
$data = curl_exec($handle);

2 个答案:

答案 0 :(得分:0)

尝试更改:

curl_setopt($handle, CURLOPT_PROXYPORT, 80);

为:

curl_setopt($handle, CURLOPT_PROXYPORT, 443);

由于https流量位于端口443上。

答案 1 :(得分:0)

curl_setopt($ curl,CURLOPT_SSL_VERIFYPEER,0);

它对我有用。

相关问题