Twitter removed XML from API – affecting ThinkTwit

Having had an issue with ThinkTwit turning half a user’s page italic (it was spewing em tags all over the place) and researching the issue I have found out that Twitter have recently changed their API to no longer support XML. Despite signs that this may be coming (as they had gradually removed XML support from other services) they did not give a timeline and this change came completely out of the blue.

For ThinkTwit users this means that for the time being you will be receiving minor issues, for example the italic problem. I am going to have to re-write a small portion of the ThinkTwit code, specifically the part that calls Twitter, to accomodate this change. As it is a key part of the program and is causing numerous users (myself included) a big issue I will make it my top priority but please bear in mind that I only have so much time every day to dedicate towards development.

Please accept my apologies for any inconvenience this is causing anyone but this was completely out of my control – if Twitter had provided a date for shutting off the XML service then I could have ensured that the fix was ready for this date, but unfortunately we are at their mercy.

I will update as soon as I have something further.


So I did a bit more checking and it appears that Twitter Search can still output XML using:

However, the returned feed has random <em> tags plastered all over it – I’m not sure if this is some way of them forcing people on to JSON or on to version 1.1 of the API…Anyway, the solution is basically to change the URL to:

And utilise JSON – this is actually pretty easy and can be done as follows:

// Decode the JSON feed
$json = json_decode($feed, true);

// Get the tweets from the JSON feed
$json_tweets = $json["results"];

// Loop through the tweets
foreach($json_tweets as $tweet) {
	// Get the content of the tweet
	$content = $tweet["text"];

	// Output the content
	echo "Tweet = " . $content;

Note that the JSON output is quite different from XML so you’ll probably have to output the array once to see what is available and then proceed from there, choosing each field as you need it but otherwise it’s plain sailing.

The next step is to start looking at Twitter Search 1.1 API (as 1.0 gets removed March 5th, 2013) but as they haven’t even released the Application only Authentication it’s a bit useless to ThinkTwit at the moment! Once they have I’ll probably release a “how to” on how to achieve this.

About Stephen Pickett

Stephen Pickett is a programmer, IT strategist and architect, project manager and business analyst, Oracle Service Cloud and telephony expert, information security specialist, all-round geek. He is currently Technical Director at Connect Assist, a social business that helps charities and public services improve quality, efficiency and customer engagement through the provision of helpline services and CRM systems.

Stephen is based in south Wales and attended Cardiff University to study Computer Science, in which he achieved a 2:1 grading. He has previously worked for Think Consulting Solutions, a leading voice on not-for-profit fundraising, Fujitsu Services and Sony Manufacturing UK as a software developer.

Stephen is the developer of ThinkTwit, a WordPress plugin that allows you to display multiple Twitter feeds within a blog.

2 thoughts on “Twitter removed XML from API – affecting ThinkTwit

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.