Could not authenticate you


#1

Hello,
I have written my own class which extends Zend_Service_Twitter. the functionality is similar to the other functions. (first the init(), setting parameter and at the end calling post-function). I have set the EncType in Zend_Http_Client to ‘multipart/form-data’ as it is documented.
GET Requests are working fine and GET account/verify_credentials is working, too. But POST occures this Error:

ErrorMessage: Could not authenticate you
ErrorCode: 32

Using
Zend 1.12.5
PHP 5.3.14

Examle Request:

POST /1.1/statuses/update_with_media.json HTTP/1.1
Host: api.twitter.com
Connection: close
Accept-encoding: gzip, deflate
User-Agent: Zend_Http_Client
Cookie: twid=u%3D1725343788%7CY611pVKbM7CH6i%2Br1Ni%2BkeuSXfU%3D;_twitter_sess=BAh7CDoPY3JlYXRlZF9hdGwrCGmjH4tGAToMY3NyZl9pZCIlMGFlNzY5ZDVh%250AMGQ3OThjNGU5YzE1ZjA3YTZmN2I4ZjM6B2lkIiU4ZWJkNTRhOTNhNjhiMGIz%250ANzZjMzYxMTEyZWU3Y2E2Yg%253D%253D–a632ea1411849916ca5399f9654a241b0a70a17f;guest_id=v1%3A140249344476018229;lang=de;
Accept-Charset: ISO-8859-1,utf-8
Authorization: OAuth realm="",oauth_consumer_key=“bBmTZTbVaziLelczV7VwqBa1U”,oauth_nonce=“df79065c315b5ed8d690c92a8016cece”,oauth_signature_method=“HMAC-SHA1”,oauth_timestamp=“1402493472”,oauth_version=“1.0”,oauth_token=“1725343788-CxwJ3G6HRl0POkrqz6dl6HZImgFdeSzNucyqNkI”,oauth_signature="z%2BuRj%2FEyWbo4ym12uYoQdOob%2Bmc%3D"
Content-Type: multipart/form-data; boundary=—ZENDHTTPCLIENT-6c7c5ce101c5dcf5f666f17e1a10486b
Content-Length: 71108

-----ZENDHTTPCLIENT-6c7c5ce101c5dcf5f666f17e1a10486b
Content-Disposition: form-data; name=“status”

sorjghkl sdaghl
-----ZENDHTTPCLIENT-6c7c5ce101c5dcf5f666f17e1a10486b
Content-Disposition: form-data; name=“media[]”
… here is the binary picture (access with the function file_get_contents(realpath($src)))…


#2

ok, I solved my issue.

what the Problem is that the Zend_Oauth_Client prepares the Oauth-Header after all Parameters were set to the Http-Client. So the oauth_signature is being generated on theses Parameters… this seems legit for all other operations but NOT for uploading a picture. So what i have done is that i have overwritten some code from zend to get this behavior:

A new Client, which extends Zend_OAuth_Client where i have overwritten the request method…similar to zends method but without the function-call prepareOauth(). Be carefull with calling parent::request() because now you have to call the request method of the Grandparent.

after this i have created my own method in my extension of the Zend_Service_Twitter where i have overwritten the post()-Method. There i hande the chronology of calling the method prepareOauth()