Zend framework OAuth / Zend_Http_Client problem sending tweet with image


I use Zend_Http_Client to tweet messages with https://api.twitter.com/1.1/statuses/update.json without problems.

But when I try to send a message with an image I receive always an error like:
“errors”:[{“message”:“Could not authenticate you”,“code”:32}]

My code is:

$config = array(
‘callbackUrl’ => ‘http://callback’,
‘siteUrl’ => ‘https://api.twitter.com/oauth’,
‘consumerKey’ => ‘XXX’,
‘consumerSecret’ => ‘XXX’

$client = $token->getHttpClient($config);
$client->setFileUpload(‘image.jpg’, ‘media[]’);
$client->request( );

What is the meaning of the error that I receive? How can I resolve?


Do you know if your OAuth library knows how to handle multipart POSTs correctly? (The rules for OAuth change a bit when the request is not of the standard URL-encoded variety). I would look into how your OAuth library is treating this request.


The problem is caused by Zend_Outh_Client, it includes “status” parameter when calculating an OAuth signature basestring or signature, this will cause error 32: “Could not authenticate you”.

You can try by removing this line,


and it will work fine.

So i think, to solve this, we need to modify Zend_Oauth_Client so that the post parameter (status) is added after prepare OAuth. Try modify request() method in Zend_Oauth_Client like the following,

public function request($method = null)
    if ($method !== null) {

   // add post parameter after prepareOauth();
    $this->setParameterPost('status', 'hello');

    return parent::request();

surely you’ll need a better fix than this


getting an error, ’ Call to undefined method stdClass::getHttpClient() ’ can anybody help ?


My solution was to send the status as GET

$client->setFileUpload(‘image.jpg’, ‘media[]’);

Hope it helps

@divaySparihar, make sure your $token is of type Zend_Oauth_Token_Access and well initialized.