When I re-designed my site earlier this year I wanted to include the last couple of twitter interactions in the footer.
Using v1.0 of the Twitter API this was a very simple process, giving access to a JSONP response with the publicly available tweets of a specified handle.
This all changed in v1.1 with the introduction of required OAuth.
Fortunately, I was able to find a work-around here which took advantage of the response made available from a widget you create.
However, the returned tweets in this solution were already styled somewhat and I could not find a unminified version of the source.
So in the end I decided to spend 45 mins last night implementing my own solution.
Using the same request method that is present in the Twitter Fetcher project (major kudos) I request the widget response, and then parse the returned tweets into objects for your callback delights.
To parse the response I decided to use ‘querySelector/querySelectorAll’ which takes away alot of the tedious DOM querying.
This script has been tested and working on IE8 but anything older in the IE family sadly does not support ‘querySelector’.
To use the fetcher all you need to do is simply create a new instance (supplying the widget id), then call ‘fetch’ with a callback of work to do with the tweets once returned and optionally a tweet limit (max of 20).
Below is an example of the one used on this site.
When the response has been parsed the supplied callback is given an array of processed tweets, each providing the following information.
I have provided a Gist of the above script for anyone wishing to make improvements/updates.