php - curl error: couldn't connect to host -
i trying use curl proxy. have following code:
function getpage($proxy, $url, $referer, $agent, $header, $timeout) { $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_header, $header); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_proxy, $proxy); curl_setopt($ch, curlopt_httpproxytunnel, 1); curl_setopt($ch, curlopt_connecttimeout, $timeout); curl_setopt($ch, curlopt_referer, $referer); curl_setopt($ch, curlopt_useragent, $agent); $result['exe'] = curl_exec($ch); $result['inf'] = curl_getinfo($ch); $result['err'] = curl_error($ch); curl_close($ch); return $result; } $result = getpage( '75.125.147.82:3128', // use valid proxy 'http://www.google.com/', 'http://www.google.com/', 'mozilla/5.0 (windows; u; windows nt 5.1; en-us; rv:1.9.0.8) gecko/2009032609 firefox/3.0.8', 1, 5); if (empty($result['err'])) { echo $results['exe']; } else { echo $result['err']; }
the output of script 'couldn't connect host'
anyone know whats wrong?
well delete code
curl_setopt($ch,curlopt_httpproxytunnel, 1);
it works me,i'm testing code luck
Comments
Post a Comment