0

我在 URL 上使用 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

这个特定的网址有什么问题?

4

1 回答 1

2

这个特定的网址有什么问题?

下划线。

来自 RFC 1912

主机名标签中允许的字符只有 ASCII 字母、数字和“-”字符。

编辑

在做了一些阅读之后,似乎 Zend 在这种情况下可能是错误的。

请参阅(域名)子域中是否可以包含下划线“_”?

根据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;
    }
}
于 2011-03-15T22:08:16.983 回答