Last.fm recent tracks Wordpress plugin
Tuesday, November 1st, 2005
I hacked together a simple Wordpress plugin for Last.fm which uses the webservice feed to display the recently played tracks on your weblog. It’s based on the del.icio.us Wordpress plugin and uses a similar layout, the same caching mechanism (to a file in /tmp) and CURL to retrieve the feed.
You can download the plugin here: lastfm.zip
To install simply unzip and copy the lastfm.php file to your /wp-content/plugins/ directory. Turn it on in your administration panel. And finally call the recent_tracks(<username>) function with your username from somewhere in your template. i.e:
<li><h2><a href="http://www.last.fm/user/tizzle/">last.fm/user/tizzle</a></h2>
<ul>
<?php recent_tracks('tizzle'); ?>
</ul>
</li>
Make sure your webhost has installed the CURL library for PHP though otherwise this plugin won’t work.
If not you could opt to use this modified version of my plugin which uses fopen instead.
Version history:
- 0.5 (16-05-2007) - small fix to account for changes in Lastfm XML format (Thanks Anthony!)
- 0.4 (09-03-2006) - changed caching behaviour and using XML instead of RSS feed
- 0.3 (01-11-2005) - moved UL tag generation into plugin
- 0.2 (01-11-2005) - fixed a caching problem
- 0.1 (01-11-2005) - initial release
