How can I use the Zend library, specifically the twitter class with codeigniter?
I'm trying to use the Zend twitter service in codeigniter.
I have used the following method to integrate zend http://www.beyondcoding.com/2008/02/21/using-zend-framework-with-codeigniter/
I can successfully complete the Oauth authentication and receive a valid access token from twitter, and my callback page works f开发者_如何学编程ine, but when I try to make a request I get the following error:
Message: Undefined offset: 0
Filename: Client/Result.php
Line Number: 232
I'm loading the twitter class like this:
$this->load->library('zend');
$this->zend->load('Zend/Service/Twitter');
I'm not sure if there's anything else I should be loading, or what I'm doing wrong.
I'm using Codeigniter 2.0.2 and ZendFramework 1.11.4
Any help would be very much appreciated.
This error doesn't seem to be related directly with CodeIgniter and Zend. Looking at the code on line 232 I can see this
return (string) $result[0];
This is within the following function
/**
* 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];
}
}
}
It appears that $result
is not an array - and to be honest this doesn't seem like a very well thought out function. Try looking into the class in question Zend/Rest/Client/Result.php
, seeing what $result
is and if the call to Twitter is actually successful.
Hope that helps.
精彩评论