Twitter v1 api retiring on 5th March #11

merged 17 commits into from Mar 13, 2013


None yet
4 participants

The v1 api that ZendService\Twitter and Zend_Service_Twitter use is retiring soon after 5th March. It will still be available 5th March, but their "blackout tests" will mean it's unstable and shouldn't be relied on.

I suggest this component and ZF1's be upgraded to v1.1. I'll see what I can do regarding it, but can't guarantee yet that I'll commit to both ZF2 and ZF1 versions.


Maks3w commented Feb 26, 2013

Any help will be well appreciated.

Reminder: ZendRest is deprecated and must be replaced with Zend\Http

I've also added a ZF 1 Jira ticket for this:

Twitter will only be supporting json in v1.1, so ZendRest unsuitable anyway as it's using xml.


weierophinney commented Feb 27, 2013

@andytson Have you begun work on this already? If not, I can start work on it tomorrow (28 Feb 2013), and likely have something to test by no later than end-of-day Friday (1 Mar 2013). Let me know, so I can plan.

sorry, no, not yet. I'm a bit busy this week outside work, and at work there'll not be enough time for a full solution (using ZF 1), so happy for you to take it.

weierophinney added some commits Feb 28, 2013

@weierophinney weierophinney Removed ZendRest as requirement
- ZendRest only worked with XML; v1.1 of twitter api is json only
@weierophinney weierophinney Added develop branch as alias d6ca14b
@weierophinney weierophinney Spring cleaning
- s/Akismet/Twitter/

andytson commented Mar 2, 2013

I've done a bit of investigation into the work needed to update the api, and found that there'll be no way to make this fully BC.

It's a heavy client, which makes it hard to test with the number of fixture files that need updating.

Is it possible since it'll be non-BC, to cut down the api function proxies so it can be a lightweight client? e.g. atm it's not even fully v1 featured, with some api functions missing and no direct way to call without adding wrapper functions in the class.

andytson commented Mar 2, 2013

Explaination behind the BC-breakage.

Many API calls changed (e.g. public/timeline -> statuses/samples, blocks/blocking/ids -> blocks/ids), and some removed (blocks/exists, friendships/exists), formats completely changed (account/rate_limit_status -> application/rate_limit_status)

XML -> JSON, some of this can maintain BC (only if assuming no api format different) with wrapping the http response in another class, apart from xpath searching, and some methods expecting simple xml objects

andytson commented Mar 2, 2013

Also it needs to have a valid access token for all api calls now.


weierophinney commented Mar 2, 2013

I've actually begun migrating the test stub files already, and am about 2/3
done after 2 days of work. I've discovered most of the BC breaks you've
mentioned, and them some. :-)

Since twitter broke BC between versions, we're left with no recourse but to
do the same.

I'll continue working on it, and port to 1.x as well.

On Saturday, March 2, 2013, Andy Thompson wrote:

Also it needs to have a valid access token for all api calls now.

Reply to this email directly or view it on GitHub

Matthew Weier O'Phinney

weierophinney added some commits Mar 7, 2013

@weierophinney weierophinney Refactored Twitter client to v1.1
- Use JSON, which means remove usage of REST client, addition of Response
  object, and renaming of "local" http client
- Replace XML response payload stubs with JSON responses
- Remove methods no longer available
- Ensure parameters are correct for exposed methods
@weierophinney weierophinney Fixed failing/errored tests that used stubs
- Removed obsolete endpoints
- Removed tests for the above
- Fixed a few tests to refer to appropriate methods
@weierophinney weierophinney All TwitterTest test cases now pass
- added screen name validation where necessary
- removed "statuses/:id/retweeted_by", as endpoint no longer exists
@weierophinney weierophinney Verified all endpoint parameters against API documentation 5da28dc
@weierophinney weierophinney Added TODO list of methods yet to implement c710b5a
@weierophinney weierophinney Normalize dynamic method/property names
- Basically, allow notation as described in API: direct_messages,
  mentions_timeline, etc. __get() and __call() now remove the underscore
  and lowercase the argument before attempting to validate.
@weierophinney weierophinney Alphabetized API method calls
- Makes it simpler to determine where new ones should be added
@weierophinney weierophinney Added search/tweets and users/search 0b57f27
@weierophinney weierophinney Search, OAuth, and HTTP Client
- Wrote tests for search
- Figured out a better way to configure both the OAuth support and HTTP
  client. You can now do the following:

  $twitter = new Twitter(array(
      'access_token' => array(
          'token'  => 'your-access-token-here',
          'secret' => 'your-access-token-secret-here',
      'oauth_options' => array(
          'consumerKey'  => 'your-consumer-key-here',
          'consumerSecret' => 'your-consumer-secret-here',
      'http_client_options' => array(
          'adapter' => 'Zend\Http\Client\Adapter\Curl',
@weierophinney weierophinney Removed old Search class
- Not necessary; all search is now done via 1.1 API
@weierophinney weierophinney Added tests for users/search f18b209

weierophinney commented Mar 7, 2013

@andytson I think this may now be ready. There were a few methods I had to remove, and I moved all search into the main Twitter class itself (as search is now exposed via the 1.1 API). Additionally, since I was breaking stuff anyways, I changed access to reflect the actual URLs of the API being used. As an example, "status->create" becomes "statuses->create" (which maps to "statuses/create"). Having the OOP API 1:1 with the Twitter API should make learning and usage easier.

I had some... fun? ... with the OAuth dance, and determined I needed to segregate different options from one another. There are now three top-level keys, one for "access_token", one for "oauth_options", and one for "http_client_options" (you can also pass in the client via "http_client" or "httpClient"). This allows you to setup the OAuth access token and consumer options easily, and tie them properly to the HTTP client.

All unit tests run now.

To configure the client to work, try the following:

use ZendService\Twitter\Twitter;

$twitter = new Twitter(array(
    'access_token' => array(
        'token'  => 'your-access-token-here',
        'secret' => 'your-access-token-secret-here',
    'oauth_options' => array(
        'consumerKey'  => 'your-consumer-key-here',
        'consumerSecret' => 'your-consumer-secret-here',
    'http_client_options' => array(
        'adapter' => 'Zend\Http\Client\Adapter\Curl',

I noted that we only cover between 10 and 25% of the entire API; as such, I created a TODO file detailing what methods still remain.

@weierophinney weierophinney CS fixes
- trailing whitespace and EOL characters
- updated TODO to remove search/tweets and users/search

weierophinney was assigned Mar 7, 2013


weierophinney commented Mar 7, 2013

Ready for review. I did this against the develop branch, as it breaks the API; we should either name the new version 3.0.0 or 2.1.0

@weierophinney weierophinney added a commit to weierophinney/zf2-documentation that referenced this pull request Mar 8, 2013

@weierophinney weierophinney Update twitter documentation
- to reflect refactoring in zendframework/ZendService_Twitter#11

weierophinney referenced this pull request in zendframework/zf2-documentation Mar 8, 2013


Update twitter documentation #718

@weierophinney weierophinney Rate limit status changed namespaces
- Now in "application" namespace instead of "account"

@akrabat akrabat merged commit 4c3a2a1 into zendframework:develop Mar 13, 2013

1 check passed

default The Travis build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment