簡體   English   中英

無法使用php和curl通過代理發出https請求

[英]Unable to make https requests via proxy using,php and curl

我們無法使用php和curl通過代理發出https請求。 我們嘗試從PHP向https://google.com發出一個簡單的curl請求,並收到消息“請求無法處理。代理或網關服務器接收到無效響應”。對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);

嘗試更改:

curl_setopt($handle, CURLOPT_PROXYPORT, 80);

至:

curl_setopt($handle, CURLOPT_PROXYPORT, 443);

由於https流量在端口443上。

curl_setopt($ curl,CURLOPT_SSL_VERIFYPEER,0);

這個對我有用 。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM