如何使用Zend库,特别是带有codeigniter的twitter类


How can I use the Zend library, specifically the twitter class with codeigniter?

我试图在codeigniter中使用Zend twitter服务。

我用下面的方法集成了zend http://www.beyondcoding.com/2008/02/21/using-zend-framework-with-codeigniter/

我可以成功完成Oauth身份验证并从twitter接收有效的访问令牌,并且我的回调页面工作正常,但是当我尝试发出请求时,我得到以下错误:

Message: Undefined offset: 0
Filename: Client/Result.php
Line Number: 232

我正在像这样加载twitter类:

$this->load->library('zend');
$this->zend->load('Zend/Service/Twitter');

我不确定是否还有其他我应该加载的东西,或者我做错了什么。

我正在使用Codeigniter 2.0.2和ZendFramework 1.11.4

此错误似乎与CodeIgniter和Zend没有直接关系。看看第232行代码,我可以看到这个

return (string) $result[0];

在以下函数

/**
 * toString overload
 *
 * Be sure to only call this when the result is a single value!
 *
 * @return string
 */
public function __toString()
{
    if (!$this->getStatus()) {
        $message = $this->_sxml->xpath('//message');
        return (string) $message[0];
    } else {
        $result = $this->_sxml->xpath('//response');
        if (sizeof($result) > 1) {
            return (string) "An error occured.";
        } else {
            return (string) $result[0];
        }
    }
}

看起来$result不是一个数组——老实说,这似乎不是一个经过深思熟虑的函数。尝试查看问题中的类Zend/Rest/Client/Result.php,看看$result是什么,以及对Twitter的调用是否实际上成功。

希望对你有帮助。