我正在尝试使用 Zend 开发一个模块,该模块将查找我的最新推文并显示在我的博客上。
我已经阅读并了解Zend_Service_Twitter
了这门课,我想我应该从我的推特上获得最新的推文。
当我启动下面给出的代码时:
public function indexAction() {
$token = unserialize('XXXXX');
$twitter = new Zend_Service_Twitter(array(
'username' => 'XXX',
'accessToken' => $token,
'consumerKey' => 'XXXX',
'consumerSecret' => 'XXXX',
'callbackUrl' => 'http://localhost/zendtest/public/blog'
));
// verify user's credentials with Twitter
$response = $twitter->account->verifyCredentials();
// Get Timeline
$response = $twitter->status->userTimeline();
$this->view->twitresponse = $response;
}
我收到此错误:
Fatal error:
Uncaught exception 'Zend_Service_Twitter_Exception' with message 'Twitter session is unauthorised. You need to initialize Zend_Service_Twitter with an OAuth Access Token or use its OAuth functionality to obtain an Access Token before attempting any API actions that require authorisation' in D:\Server\xampp\htdocs\zendtest\library\Zend\Service\Twitter.php:282
Stack trace:
#0 D:\Server\xampp\htdocs\zendtest\library\Zend\Service\Twitter.php(769): Zend_Service_Twitter->_init()
#1 [internal function]: Zend_Service_Twitter->accountVerifyCredentials()
#2 D:\Server\xampp\htdocs\zendtest\library\Zend\Service\Twitter.php(270): call_user_func_array(Array, Array)
#3 [internal function]: Zend_Service_Twitter->__call('verifyCredentia...', Array)
#4 D:\Server\xampp\htdocs\zendtest\application\modules\twitter\controllers\TwitterServiceController.php(27): Zend_Service_Twitter->verifyCredentials()
#5 D:\Server\xampp\htdocs\zendtest\library\Zend\Controller\Action.php(516): Twitter_TwitterServiceController->indexAction()
#6 D:\S in D:\Server\xampp\htdocs\zendtest\library\Zend\Controller\Plugin\Broker.php on line 336
我在互联网上和这里有很多文章,但仍然无法解决我的问题。
有谁知道如何处理这个问题?
和有什么共同点Zend_Oauth_Consumer
?