03rd December, 2014 by Ian Campbell

How To Get Your Twitter Feed Back On Your Website After The API 1.1 Update.

Prior to June 2013 using Twitter API version 1.0 it was possible to access certain data from Twitter anonymously and most websites (like ours) were using JavaScript to do things like show latest tweet or recent tweets. There are (or were) in fact ready made jQuery libraries created which allowed this functionality very easily such as jQuery Tweet and Twitter’s own blogger.js.

In June 2012 Twitter announced breaking changes in API version 1.1 and that 1.0 would be retired in March 2013. Obviously few people took any notice of this an continued to use 1.0 until March when Twitter extended the life of 1.0 for a few months up to June 2013. It is now retired and the old jQuery and javascript methods used to pull in latest tweets etc will no longer work.

Twitter API Changes

So, apart from the well prepared developers who moved to 1.1 a year ago, basically this has resulted in many many sites displaying something similar to this….

Lost Connection

SO WHY HAVE TWITTER DONE THIS …

 

The main breaking change is that every request to the API now requires authentication so Twitter knows who is accessing their data. Why we need to do this to access a publicly available feed is not know, however the key reason from Twitter is  To prevent malicious use of the Twitter API and gain an understanding of what types of applications are accessing the API in order to evolve it to meet the needs of developers

AND WHAT DID WE DO TO FIX IT…

 

On the IADigital site we were using blogger.js and the REST API via the following URLhttps://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=iadigital&count=1

Since the 1.0 API was retired this now returns

{"errors": [{"message": "The Twitter REST API v1 is no longer active. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.", "code": 68}]}

From reading the developer documentation and some handy forum posts we proceeded to use a .NET solution calledoAuthTwitterTimeline by Andy Hutch.

We generated an oAuth consumer key and secret from Twitter at:

https://dev.twitter.com/apps/new then added our consumer key and secret to the oAuthTwitterTimeline code file. When complied this created a secure authenticated link to our Twitter timeline from server side code and output the JSON reponse to a standalone .aspx page.

www.iadigital.com/TwitterTimeline.aspx

We are then able to continue to use the same JavaScript code to pull the twitter feed on to our homepage just by updating the feed URL. No other changes were required.

We have since updated the oAuthTwitterTimeline code to read the Twitter authentication and configuration / settings from the website web.config file so the same .dll and .aspx file can be used across multiple websites.

About author

Ian Campbell

Writes code like he plays the drums. Like a mad man! Our Technical Director is the only developer on the planet who can work on three hugely complex projects at a time without breaking a sweat.

Comment
We are always here to help you. Don’t hesitate to contact us anytime!

01202 555124 or hello@envisagecms.co.uk