LastFM PHP is an easier way for developers to access the LastFM API. Forked from https://github.com/Crucider/LastFM-PHP
You must require the class inside of your PHP file. The class can be found here: https://github.com/Kiwithing/LastFM-PHP/blob/master/lastfm.php
require 'lastfm.php';
To start the class, you have to add in Options (remember this for later on).
$lastfm = new LastFM(array(
'USER' => 'Username Here',
'APIKEY' => 'API Key Here'
));
Options available:
- USER
- APIKEY
Parameters:
- Limit
- Integer. (Default = 5) Amount of songs to grab.
Requirements:
- Options
- USER
Example:
foreach($lastfm->getSongs(5) as $song) {
echo $song['NAME'] . ' by ' . $song['ARTIST'] . '<br>';
}
Parameters:
- Method
- String. The API method to use that can be found here: http://www.last.fm/api
- Parameters
- Array. The parameters to use that can be found on the method page. Example: http://www.last.fm/api/show/album.getInfo
Requirements:
- Options
- APIKEY
- Parameters
- Method
- Parameters
Example:
$lastfm->getCustom('album.getinfo', array(
'artist' => 'Beast',
'album' => 'Fiction And Fact'
));