Zend HTTP客户端无效的URI?

时间:2011-03-15 22:05:57

标签: zend-framework zend-http-client

我在网址上使用Zend HTTP时遇到问题:

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

出于某种原因,这给了我一个错误......

Invalid URI supplied

这个特定的网址错了吗?

1 个答案:

答案 0 :(得分: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;
    }
}