2012-11-24 89 views
1

我有一個自定義的PHP代理類=>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; 
    } 
} 

其中我的init像這樣=>

$proxy = new Proxy("PROXY_IP:PROXY_PORT"); 
    $content = $proxy->get_page($url); 

,一切都是前工作正常,直到幾天。現在我不斷收到主要與Received HTTP code 403 from proxy after CONNECT相關的錯誤消息。 因爲我不知道未經修改的代碼如何停止工作 - 我不知道如何調試此問題。

任何幫助,將不勝感激。 謝謝!

編輯: 我知道什麼403狀態碼的意思,我只是說我得到403無論我使用什麼代理,無論我嘗試使用它的哪個網頁。

回答