TXP Plugins
arc_lastfm (early beta release) :: Jul 27, 07:40 PM
This plugin is very much in the experimental stage at the moment, but I am releasing what has been put together so far as a beta version of the plugin. The aim is to have a single plugin that enables you to tap into the rich resource of information on the excellent social music website last.fm using its API.
In its current state it solely outputs a user’s recent track listing from last.fm. It uses my last.fm class, a library of functions to access the various methods available through the API. It should be apparent from the arc_lastfm class that there is a great deal of expansion planned for this plugin.
arc_lastfm requires PHP5+ as it makes uses of SimpleXML and PHP5’s improved object orientation.
Installation
To install go to the ‘plugins’ tab under ‘admin’ and paste the plugin code into the ‘Install plugin’ box, ‘upload’ and then ‘install’. Finally activate the plugin.
Syntax
<txp:arc_lastfm api=”your_API_key“ user=”lastfm_username“ />
Usage
In order to use the last.fm API you will need to get an API key from last.fm. Once you’ve got your key you will need to set the api attribute with it when you use the plugin.
| Attribute | Description | Default | Example |
|---|---|---|---|
| api | Your API key (required) | unset | |
| user | last.fm user name | unset | user=“monkey-ninja” |
| label | Label for the top of the list | no label | label=“Recent tracks” |
| labeltag | Independent wraptag for label | unset | labeltag=“h3” |
| break | HTML tag (without brackets), or string, used to separate the tracks | li | break=“br” |
| wraptag | HTML tag to be used as the wraptag, without brackets | unset | wraptag=“ul” |
| class | CSS class attribute for wraptag | arc_lastfm | class=“lastfm” |
Caching
In order to prevent excessive repeatitive calls to the last.fm website it is recommended to cache results. Your last.fm account may be suspended if you continuously make several calls per second. By default, arc_lastfm caches for 5 minute intervals.
| Attribute | Description | Default | Example |
|---|---|---|---|
| caching | ‘1’ to cache feed, ‘0’ to turn caching off (not recommended) | 1 | caching=“1” |
| cache_dir | Absolute path to the cache directory (must be writable) | ||
| cache_time | Time in minutes that the cache files are stored before being refreshed | 5 | cache_time=30 |
Future plans
All will be revealed in good time!
Plugin details
Initial release: 27 July 2009
Current version: 0.1.0beta
[ download ]
Please feel free to leave your comments and questions about this plugin below.
Use of my plugins is free; however, if you would like to show your appreciation you can do so by clicking the 'Donate' button below and make a contribution to the Andy Carter's coding fund via PayPal...
Comment
Recent plugins
Textpattern links
Textpattern forums
Textpattern's support forums.
Textpattern Resources
A directory of plugins, tutorials, and other resources for and by the Textpattern community.
TXP Tips
Tips, tutorials, and code to help build better Textpattern websites.
We Love TXP
Design gallery of sites using Textpattern.