为什么我的 cURL 不能与代理一起使用?我试过使用几个代理,它所做的只是给我一个白屏。
这是PHP代码:
function curl($url){ // Defining the basic cURL function
$proxy = '122.166.5.84:8080';
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.168 Safari/535.19');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
//curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxy_userpass);
$data = curl_exec($ch);
if($data === false || curl_error($ch)) {
return $data;
}else{
curl_close($ch);
return $data;
}
}