[Wordpress Plugin] Twitter User Tags

14/01/2009

It seems to be almost habit-forming, my chats with Thomas at sharebrain lately. He has a habit of having these little ideas for sites and WordPress hacks that I just can't resist! So we were chatting last night, and he wanted to be able to quickly insert a user's Twitter profile image into a WordPress post. This seemed like a cool idea, but I wanted to take it further and be able to insert any user info, rather than just the image. So here it is, I present, the Twitter User Tagging thinger: <!--more--> download.

How to use: Firstly, you'll need to install the plugin. Like any other, put this in your plugins directory and go to your admin panel to activate. To decrease the impact on the twitter API, this plugin caches everything you request, so you'll need a cache directory. The default is "/lib/cache/" so you'll need to make sure that directory exists and is writable. If you don't like that directory, create your own, make sure it is writable and edit the following:

/** * the directory to put cached images in - with the first and last / */ private $cache_dir = '/lib/cache/';

It is really important to leave the first and last "/" characters in there, or you'll get errors. Don't say I didn't warn you.

If you've ever used Smarty or anything like it, you'll recognise this straight away. To insert information about a user, insert a tag in this format:

{twitter:username:info}

so inserting {twitter:jaspertandy:profileimageurl} will insert http://s3.amazonaws.com/twitter_production/profile_images/62898698/DSC_0004_normal.jpg and {twitter:jaspertandy:description} will insert "Camera-wielding, web-developing lover of cute, fluffy things." without the quotes, obviously.

There is some information (regarding status updates) that is nested in the format parent/child. To insert this type of data, use the format {twitter:jaspertandy:status/text}, which will insert "@tommsinclair you have to have a BT line - bout £11.50 p/m then you have the internet set up on top of that.".

This plugin uses the twitter API, specifically the show function. To see what you can get, follow the instructions there and you'll see what you can embed.