2011-03-15 130 views
0

我在使用上的URL Zend的HTTP麻煩:Zend HTTP客戶端URI無效?

$client = new Zend_Http_Client('http://xxfire_killumiex.api.channel.livestream.com/2.0/info.json'); 
$feed = $client->request()->getBody(); 

出於某種原因,這給了我一個錯誤...

Invalid URI supplied 

哪些錯誤這此特定網址?

回答

2

這是什麼錯這個具體的網址?

下劃線。

從RFC在主機名稱的標籤,1912年

字符是唯一的ASCII 字母,數字和' - 」字符。

編輯

做一些更多的閱讀後,似乎Zend的可能是錯誤在這種情況下。

Can (domain name) subdomains have an underscore "_" in it?

ZF-9671,你可能是出於運氣,雖然我已經重開的問題。

我在此期間的建議;創建你自己的這樣的HTTP客戶端類

class My_Http_Client extends Zend_Http_Client 
{ 
    public function validateHost($host = null) 
    { 
     if ($host === null) { 
      $host = $this->_host; 
     } 

     // If the host is empty, then it is considered invalid 
     if (strlen($host) === 0) { 
      return false; 
     } 

     return true; 
    } 
} 
+0

我跑了一個str_replace用%5F替換它,它沒有什麼區別。無論如何,下劃線都是有效的URI字符,爲什麼它會成爲一個問題? – 2011-03-15 22:14:35

+0

@Jason查看我的編輯 – Phil 2011-03-15 22:16:43

+0

@Jason這裏是一個ZF用來驗證URI的正則表達式'preg_match('/^[0-9.ae:.]*$/i',$ value)' – criticus 2011-03-15 22:19:39