Welcome Guest, Not a member yet? Register   Sign In
Last.FM Library
#1

[eluser]essdeesee[/eluser]
Hi.

I have written a simple last.fm library (PHP 5 only...maybe for now)

It will just make the process of grabbing the data for different feeds a bit easier for you.

Usage is simple.

Controller:
Code:
$this->load->library('lastfm');


$config = array('user' => 'lastFMName', ‘feed’ => ‘topalbums’, ’start’ => 0, ‘amount’ => 6);
$this->lastfm->init($config);
$data['lastfm'] = $this->lastfm->getData();

View:
Code:
print_r($lastfm);

Of course, you can then do whatever you want with that data. For example, my top albums output looks like.

Code:
foreach ($lastfm as $album)
{
?>
   <li>
       <span>
           <a href="&lt;?=$album['url']?&gt;" title="#&lt;?=$album['rank']?&gt; . &lt;?=$album['artist']?&gt; - &lt;?=$album['name']?&gt;">
              <img src="&lt;?=$album['image']['medium']?&gt;"/>
           </a>
    </span>
   </li>    
&lt;?
}

You can get the library Here, the returns and feed types are defined at the top of the file.

Honestly, the whole idea of me even putting this up is to save someone elses time. I hope it does.

Todo:
-Image Caching
-PHP 4 Support (Maybe)
-Feed Caching?


Messages In This Thread
Last.FM Library - by El Forum - 06-14-2008, 10:02 AM
Last.FM Library - by El Forum - 06-15-2008, 04:31 AM
Last.FM Library - by El Forum - 07-08-2008, 02:14 PM
Last.FM Library - by El Forum - 07-08-2008, 06:16 PM
Last.FM Library - by El Forum - 08-18-2008, 08:06 AM
Last.FM Library - by El Forum - 08-19-2008, 07:46 AM
Last.FM Library - by El Forum - 03-17-2011, 05:08 PM
Last.FM Library - by El Forum - 08-07-2011, 11:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB