Integrate Twitter On your website

So I had my twitter status being displayed over at http://crimm.me and unfortunately the code I was using seems to have flooded Twitter and Twitter decided to deliver a 503 error code to me :)

So instead of re-inventing the wheel, I decided to go out and look for one that was already written. I found the most wonderful … I mean WONDERFUL tutorial and I wanted to share it with you guys.

The original is here. The outcome can look like my personal site http://crimm.me.

Basically here’s what you want to do:

Step 1: Download the zip file from the selfconclusion.co.uk site above
Step 2: Open the index.php and edit it, making sure to replace:

http://search.twitter.com/search.atom?q=from:USERNAME

with your username :)

Also pay close attention to this line:

<?php foreach ($feed->get_items(0, 4) as $item): ?>

Change that 4 to a 1,2,3, etc for as many status’ as you want to be displayed.

Step 3: Create a “cache” folder on your website
Step 4: Open the simplepie.inc and look for line 500:

var $cache_location = ‘./cache’;

I HIGHLY suggest that you take the ./cache and change that to an ABSOLUTE path. For example:

var $cache_location = ‘/var/www/htdocs/crimm/cache’;

The reason being is because if you include this script on multiple folders, pages, subdomains, etc … You will have issues with path problems.

Step 5: Upload the 2 files: index.php and simplepie.inc to your server
Step 6: Include and output index.php with the following code:

<?php include (‘php/twitter.php’) ?>

There you go… 6 easy steps and it works out of the box. There seems to be TONS more customization to it, and I’ll leave it to you to play with; as I’m happy with it now :)

I hope that helps someone out there :)

Author:  Crimm

Software engineer (PHP, Bat, VBS), Sr. Systems Admin, Techie, Father, Gamer, Anime watcher (Wannabe Otaku), & full of geek!