我有一个自定义的 php 代理类 =>
class Proxy
{
private $proxy,
$header,
$timeout,
$agent;
public function __construct($proxy, $header = null, $timeout = null, $agent = null) {
$this->proxy = $proxy;
$this->header = empty($header) ? 1 : $header;
$this->timeout = empty($timeout) ? 5 : $timeout;
$this->agent = empty($agent) ? "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8" : $agent;
}
public function set_proxy($proxy) {
$this->proxy = $proxy;
}
public function get_page($url, $referer = "http://www.google.com/") {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, $this->header);
curl_setopt($ch, CURLOPT_PROXY, $this->proxy);
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->timeout);
curl_setopt($ch, CURLOPT_REFERER, $referer);
curl_setopt($ch, CURLOPT_USERAGENT, $this->agent);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = array();
$result['exe'] = curl_exec($ch);
$result['inf'] = curl_getinfo($ch);
$result['err'] = curl_error($ch);
curl_close($ch);
return $result;
}
}
我喜欢这样=>
$proxy = new Proxy("PROXY_IP:PROXY_PORT");
$content = $proxy->get_page($url);
直到几天前,一切都运行良好。现在我不断收到主要与Received HTTP code 403 from proxy after CONNECT
. 由于我不知道未经修改的代码如何停止工作 - 我什至不知道如何调试这个问题。
任何帮助,将不胜感激。谢谢!
编辑:我知道 403 状态码是什么意思,我只是说无论我使用什么代理,无论我尝试使用哪个页面,我都会得到 403。