如何在ssl curl中使用proxy

时间:2017-08-13 12:26:02

标签: php ssl curl

我可以在php中使用ssl curl而没有问题但是当设置代理时我无法打开网站

这个例子我希望得到帮助

$url="https://www.digicert.com";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_NOBODY, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 3);
curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) .'/cert.pem'); 
curl_setopt($ch, CURLOPT_CAPATH, dirname(__FILE__) .'/cert.pem'); 
curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__) .'./cookie.txt');
curl_setopt($ch, CURLOPT_COOKIE, "cookiename=0");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_PROXY,'xxx.xxx.xxx.xxx:8080');
echo curl_exec($ch);
var_dump(curl_error($ch));


echo "curl_errno: ".curl_errno($ch)."<br>"

0 个答案:

没有答案