PHP connection via proxy
Hello everybody! Why doesn't it connect? It works without a proxy. And with a proxy, a blank screen. What is the error? Curl modules are installed.
<?php
//error_reporting(E_ALL);
if( $ch = curl_init ())
{
curl_setopt ($ch, CURLOPT_URL, 'http://www.ya.ru');
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_setopt ($ch, CURLOPT_PROXY, "79.136.243.142:3128");
curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt ($ch, CURLOPT_FAILONERROR, true);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
$result = curl_exec($ch);
//print curl_errno ($ch);
//print $result;
echo $result;
curl_close ($ch);
}
?>
1
1 answers
Most likely due to the fact that the proxy server is not socks5.
Try putting CURLPROXY_HTTP
instead of CURLPROXY_SOCKS5
, if it works, then it is.
1
Author: Alex Kapustin, 2012-05-23 21:08:38