Take the 2-minute tour ×

The Zend_Service_Twitter component is still for Twitters API v1.0 which will be deprecated at 5th March 2013. So I wanted to make my new website with Twitter API interaction v1.1 ready. Everything works fine with v1.0 but if I change the URL from /1/ to /1.1/ it fails with the HTTP header code 400 and the JSON error message: Bad Authentication data (Code: 215)

To get the request and access token stayed the same and works already without any changes, but if I want to verify the credentials like this I get the error I described above:

// Take a look for the code here: http://framework.zend.com/manual/1.12/en/zend.oauth.introduction.html
$accessToken = $twitterAuth->getAccessToken($_GET, unserialize($_SESSION['TWITTER_REQUEST_TOKEN']));

// I have a valid access token and now the problematic part
$twitter = new Zend_Service_Twitter(array(
    'username' => $accessToken->getParam('screen_name'),
    'accessToken' => $accessToken

I changed the code of verifyCredentials in Zend/Service/Twitter.php from that to that:

public function accountVerifyCredentials()
    $response = $this->_get('/1/account/verify_credentials.xml');

// to

public function accountVerifyCredentials()
    $response = $this->_get('/1.1/account/verify_credentials.json');
    return Zend_Json::decode($response->getBody());

Now I added before the return Zend_Json[...] this line:


// And I get this output of it:

GET /1.1/account/verify_credentials.json HTTP/1.1
Host: api.twitter.com
Connection: close
Accept-encoding: gzip, deflate
User-Agent: Zend_Http_Client
Authorization: OAuth realm="",oauth_consumer_key="",oauth_nonce="91b6160db351060cdf4c774c78e2d0f2",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1349107209",oauth_version="1.0",oauth_token="hereismytoken",oauth_signature="hereisavalidsignature"

As you could see the oauth_consumer_key (and realm too) is empty. Could that be the error? How could I solve this error (because of the stricter new API version?)? Would it be fine to set somehow the oauth_consumer_key? If yes, how could I manage that?

Edit: I also found already a bug report on the issue tracker of the Zend Framework: http://framework.zend.com/issues/browse/ZF-12409 (maybe do an upvote?)

share|improve this question

4 Answers 4


        $options = array(
            'oauthOptions' => array(
share|improve this answer
Thanks a lot. Helped me a lot. –  Peter O. Jun 19 '13 at 9:29
There is also a change in calling the status update function. status has been changed to statuses, $twitter->statuses->update('...') –  Peter O. Jun 19 '13 at 9:39

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,
share|improve this answer

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.



share|improve this answer
That's not a very descriptive class name. And shouldn't it be in a different namespace if Zend didn't write it? I realise it's just tweaks but it's good practice to use a different namespace if you override a class. –  voidstate Mar 14 '13 at 11:55
It's only example. –  yAnTar Mar 14 '13 at 15:23
    $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();

    $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);


share|improve this answer

Your Answer


