// 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