Creating an RSS feed for your Twitter home page

Updated to use v1.1 of the Twitter API on 2-Mar-2013. See comments below for notes on updating.
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.

https://api.twitter.com/1/statuses/user_timeline.rss?screen_name=username

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.

http://www.mysite.com/twitter.rss.php

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(
        	'GET', 
			$tmhOAuth->url('1/statuses/home_timeline'), 
			array(
          		'include_entities' => true,
    			'count' => 50,
        	)
        );

See https://dev.twitter.com/docs/api/1.1 for other options.

All Over

That was it – that was the last day, all done, just a sleep and I’m coming home.

Quite an eventful day really – dropped off my pack at the hotel then when and had coffee at about 7. A Japanese woman came to talk to me, this is nice I thought, not many are so friendly. Then it became apparent that she was drunk (she said she worked nights) and that she was actually trying to pick me up! So I had a train that I just had to catch.

So I went of the Shibuya area, this is a bit more up market – shops for Amarni, Jimmy Choo, Ralph Lauren (well their the names I recognised). Had a good wander, found another garden and shrine… the one where the Gothlollis hang out . Not many about as they were starting some vintage car event there and I think that had kept them away. So no TV program is complete without such a picture… why should I be different.

image

Shinjuku

I spent last night in Shinjuku because that’s where the capsule hotel was. Left my pack in a station locker and just took the small one when I booked in. Luckily there was a staff guy there who had a few English words. So I worked out how the locker worked (very narrow locker) and went back out.

God! that place is busy on a Friday night. Did the calm aee with the skyscrapers first. You get a grest view from 53rd floor. A shrimp buger… then into the mad area. To be honest compared to my first night I found it a little scary. Not in a worried about my safety scary, but in a “my god I don’t understand what’s going on and there are too many people way”. I even had a couple of different guys come and tout me, one for a topless bar, no idea where the other wanted me to go.

The thing that kept popping into my head was the city from Bladerunner.

Survived!

Survived my night in a capsule hotel. It was quite cozy really.

Last day! Shopping for small things I can fit in my bag.

Hiroshima

Well yes… I saw the dome, the park, the memorial and the museum. The memorial hall with the personal descriptions and testaments is very moving.

The "A-Bomb" Dome
The cenotaph

A quick look at the castle and then a tram and ferry to Miyajima. Very pretty once again… has wild deer in the streets, cable cars, mountains and monkeys….

The famous tori
The "floating" shrine

Nearly over, a day travelling tomorrow and an evening and a day left in Tokyo…. I hope I can get into a capsule hotel!

Trains again

There I was getting nervous about a 5 minute slot to change trains at Okayama. I needn’t have worried – we get in on time, my second train is due in on the opposite side of the platform…. and yes…. arrives bang on time.