Twitter API
Wednesday 19th June, 2013 15:48 Comments: 0
It took me about a week to notice that the tweets displayed on my home page hadn't updated, due to the excellent validation and caching of data that I'd implemented. It turns out that Twitter have finally stopped supporting their original API. To be fair to them, they did announce almost a year ago that this was going to happen, and then extended the date until June 11th.
Normally a minor release would mean hardly any changes. I figured it'd be a few simple tweaks to my existing code. I was wrong.
Firstly, XML, RSS, and ATOM support has been dropped (I used XML before). They only support JSON output (luckily, PHP has decent support for JSON).
Secondly, you need to authenticate using OAuth. The entire 1.1 API requires a user context when authenticating, so an oauth_token representing an access token must be present in each request. It turns out you can log into https://dev.twitter.com/apps with your Twitter account and create an application to generate an OAuth token. Simples.
After that it wasn't difficult to use my existing code to validate and cache (and make pretty) the same information that I'd been accessing before.
For more information, the REST API v1.1 is available here. With all the changes, I would have called it v2.0.
Normally a minor release would mean hardly any changes. I figured it'd be a few simple tweaks to my existing code. I was wrong.
Firstly, XML, RSS, and ATOM support has been dropped (I used XML before). They only support JSON output (luckily, PHP has decent support for JSON).
Secondly, you need to authenticate using OAuth. The entire 1.1 API requires a user context when authenticating, so an oauth_token representing an access token must be present in each request. It turns out you can log into https://dev.twitter.com/apps with your Twitter account and create an application to generate an OAuth token. Simples.
After that it wasn't difficult to use my existing code to validate and cache (and make pretty) the same information that I'd been accessing before.
For more information, the REST API v1.1 is available here. With all the changes, I would have called it v2.0.