I used to read my twitter feed (the tweets you see on your Twitter home page) in an RSS reader, but when Twitter stopped providing that feed I was unable to do so. There are still some feeds supported until March 2013 but they show just your own tweets, tweets from a particular user or for a particular hash tag. e.g.
To get RSS reading back again I decided to create my own feed and you can do the same. I made heavy use of Adam Green’s code from 140dev.com and he in turn uses Matt Harris’ OAuth library from https://github.com/themattharris/tmhOAuth.
You will need web hosting that supports PHP and you can down load the files I used here (twitter-v1.1.zip updated 2-Mar-2013) and extract them to your computer.
You will also need to get some access keys from Twitter so go to https://dev.twitter.com/apps (you will need to log in with your Twitter name and password).
Click on the create a new application button then provide a name, description and a URL for the application (the URL is just where people can find out about your code – in my case it’s the blog page you’re reading).
The Callback URL is not required in this case. But if you want you can give the URL where your feed is going to be for example http://www.mywebsite.com/twitter/rss.php
Accept the terms and complete the captcha and you will be taken to the settings pages for your application.
Go to the settings tab and select Read only as the application type and update the settings.
Go back to the details tab and click the “create my access token” button at the bottom.
You will now have a page with a number of codes, you will need to copy the values for
- Consumer key
- Consumer secret
- Access token
- Access token secret
Now go to the files you downloaded, find the keys folder and in that folder is a file called personal_keys.php. Open it and edit it replacing the dummy values with the ones you copied above.
Also replace the entries in the personal_keys.php file for the domain where you will be hosting the feed. (Thanks to Terry for pointing out my earlier errors.)
Now simply upload the entire folder to your web site and test the feed by entering the appropriate URL into a browser e.g.
Note, the feed is not secure and anyone with the URL can read the feed. It would be possible to have a password protected feed if you wanted to do some extra work but as tweets are public anyway I decided it wasn’t necessary for my purposes.
If you wanted something other than the home timeline you can change the URL you use to request data in the rss.php file.
$code = $tmhOAuth->request(
'include_entities' => true,
'count' => 50,
See https://dev.twitter.com/docs/api/1.1 for other options.