About the documentation i've been reading: You mentioned i should look at this one: http://framework.zend.com/manual/2.1/en/modules/zendservice.twitter.html
At first I've been reading the 2.0 version, because that's the Zend Framework version i was using (although i've upgraded this weekend to 2.1). I find it very confusing that the Twitter service is categorized and updated only in a branch of Zend Framework, when it is not shipped with Zend Framework, but has to be installed as a seperate component. Apart from that: the information in the 2.0 version is not even relevant anymore, simply because there's no way it is gonna work for anyone as the 1.0 Twitter API is being trashed as we speak. A warning at the top of the page would be nice, because when i read documentation that corresponds with the version i'm using i expect it to still work. I didn't bookmark any of the outdated pages that i've read so i can't give yo a full list, but i remember this was one of them: https://zf2.readthedocs.org/en/latest/modules/zendoauth.getting-started.html Not a ZendService/Twitter page, but one that has an outdated example, nonetheless. > [you said:] > It also notes that a token is required for all actions except retrieving > the public timeline. I find the documenation on both the ZF website and the Twitter website not clear about this. The twitter website clearly states that _all_ actions need to be authenticated. To me this sounds like i always need to communicate an access_token. The ZF website states you don't need a token for the public timeline and when you try this out by pasting this request into your browser: https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=twitterapi&count=2 You get a bad authentication error which suggests that statement is not true. In the end i realized the truth lies somewhere in the middle: you don't need to do a request for a token, but you _do_ need to communicate a token (one that you can request on the twitter configuration page of your application). Anyways, i've been reading the 2.1 documenation as well and as you can see, the last code-snippet in my original post contains an example that resembles the example on that page (except for the curl part), but it still doesn't work. I also know why it doesn't work. - verifying the credentials: i've captured the request and it fails because the token isn't communicated anywhere in the request (see my original post) - reading a public timeline : here is the code i'm using: <?php $adapter = new \MyOwn\Http\Client\Adapter\Curl(); $adapter->setCurlOption(CURLOPT_SSL_VERIFYPEER, false); $twitter = new \ZendService\Twitter\Twitter(array( 'access_token' => array( // or use "accessToken" as the key; both work 'token' => '[mytoken]', 'secret' => '[mysecret]', ), 'oauth_options' => array( // or use "oauthOptions" as the key; both work 'consumerKey' => '[mykey]', 'consumerSecret' => '[mysecret]', ),/* 'http_client_options' => array( 'adapter' => 'Zend_Http_Client_Adapter_Curl', ),*/ )); $twitter->getHttpClient()->setAdapter($adapter); $options = array( "screen_name" => "someuser" ); $response = $twitter->statuses->userTimeline($options); ?> And this is the request that is sent: 'GET /1.1/statuses/user_timeline.json?screen_name=someuser HTTP/1.1 Host: api.twitter.com Connection: close Accept-Encoding: gzip, deflate User-Agent: Zend\Http\Client Authorization: OAuth realm="",oauth_consumer_key="gg3DsFTW9OU9eWPnbuPzQ",oauth_nonce="6b30716c90b9bb42d01088ee4f548854",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1368449269",oauth_version="1.0",oauth_token="1413036372-kHjVix9Q4uZXrNwGDZZYS0NbALgRgNrxy2iiaZY",oauth_signature="8vO4dDXaaB1IdAJ%2Fj242b0SkBIg%3D" The response: a 401 with the body: {"errors":[{"message":"Could not authenticate you","code":32}]} This is because the authorization header is wrong (not according to twitter specifications) and this is exactly the reason why i had so much problems getting ZendOAuth to work. In the end i had to extend a whole bunch of classes to be able to overwrite this header and make it work according to the specifications i found on the twitter website. One more observations about this: i've commented out the http_client_options config because that resulted in a Fatal error: Fatal error: Cannot redeclare class Zend\Http\Client\Adapter\Curl in C:\wamp\www\anvtv\anvtv-src\vendor\zendframework\zendframework\library\Zend\Http\Client\Adapter\Curl.php on line 23 The reason i'm using my own extended curl adapter is partly because that way i'm able to capture the request and output it to the screen. It simply extends Zend's Curl class though. -- View this message in context: http://zend-framework-community.634137.n4.nabble.com/various-ZendService-Twitter-problems-due-to-recent-API-change-tp4660002p4660014.html Sent from the Zend Framework mailing list archive at Nabble.com. -- List: [email protected] Info: http://framework.zend.com/archives Unsubscribe: [email protected]
