Zend_Service_Twitter - Make API v1.1 ready

六月ゝ 毕业季﹏ 提交于 2019-12-03 23:45:18

with ZF 1.12.3 the workaround is to pass consumerKey and consumerSecret in oauthOptions option, not directrly in the options.

        $options = array(
            'username' => /*...*/,
            'accessToken' => /*...*/,
            'oauthOptions' => array(
                'consumerKey' => /*...*/,
                'consumerSecret' => /*...*/,
            )
        );

While you wait to fix this issue in Zend_Twitter_Service component, you can do this workaround:

You need to send customerKey and customerSecret to Zend_Service_Twitter

$twitter = new Zend_Service_Twitter(array(
                'consumerKey' => $this->consumer_key,
                'consumerSecret' => $this->consumer_secret,
                'username' => $user->screenName,
                'accessToken' => unserialize($user->token)
));

Today I have the same problem - Zend Framework works with API 1.

I created new class like

class Zend_Service_Twitter11 extends Zend_Service_Twitter

And override functions, which I need.

statusUpdate
statusReplies

etc

sanek
    $this->_session = new Zend_Session_Namespace('auth_twitter');
    $config = Zend_Registry::get('config')->twitter->toArray();
    $access_tokenSession = unserialize($this->_session->access_token);



    $accessToken = new Zend_Oauth_Token_Access();
    $accessToken->setToken($access_tokenSession->oauth_token);
    $accessToken->setTokenSecret($access_tokenSession->oauth_token_secret);

    $temp = array();
    $temp['oauthOptions']['consumerKey'] = $config['consumerKey'];
    $temp['oauthOptions']['consumerSecret'] = $config['consumerSecret'];
    $temp['accessToken'] = $accessToken;
    $temp['username'] = $access_tokenSession->screen_name;


    $this->_twitter = new Zend_Service_Twitter($temp, null);

    $this->_twitter->account->accountVerifyCredentials()->toValue()
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!