Professional Freelance Web Developer
CodeIgniter Activist, Caffeine Junkie

Elliot Haughin

Lastfm CodeIgniter Library

LastfmSharing your music taste could never be easier with CodeIgniter and Lastfm

Just register for lastfm, and install the program on your PC/Mac… then play your tunes in your favourite music player. The ‘recently played’ list will start populating with your track list.

You can use this library to get a list of your recently played songs (like on the right hand side of this blog >>), for your CodeIgniter application.

Using the application is really simple.
Here’s the code for your controller:

$this->load->library('lastfm');
 
$config = 	array(
'user'	 => 'elliothaughin',
'num'	=> 10,
'rss_cache_path'	=> APPPATH.'cache/lastfm-rss-cache',
'cache_time'	=> 300 // 5 minutes
);
 
$this->lastfm->init($config);
 
$data['lastfm'] = $this->lastfm->get_latest();

Then you just need to display them in your view files!

<?php foreach ($lastfm as $song):?>
<li><?=$song['title']?><br />
<?=$song['when']?></li>
<?php endforeach; ?>

Easy peasy huh?

Download Lastfm CodeIgniter Library

REQUIRES: Simplepie CodeIgniter Library

Version: 1.0

Boring Stuff

Design © copyright Elliot Haughin 2009

Content published here are copyright their respective owners.

You cannot copy content from this site, either in English or translated to another language.

Keep Subscribed

Theres lots of ways for you to keep up with me on the web.

Please Note

Information given out on this blog should only be used as a guideline. I hold no liability for any code I write.

Always consult a professional before acting on this guidance.