1. Go to this page and download the library: Download thatobabusi/laravel-lastfm library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Thatobabusi\LaravelLastFm\Lastfm;
public function topAlbums(Lastfm $lastfm)
{
$albums = $lastfm->userTopAlbums('username')->get();
return view('albums', compact('albums'));
}
use Thatobabusi\LaravelLastFm\Constants;
// Filter by time period
$lastfm->userTopAlbums('username')
->period(Constants::PERIOD_MONTH)
->get();
// Limit results
$lastfm->userTopAlbums('username')
->limit(5)
->get();
// Paginate through results
$lastfm->userTopAlbums('username')
->limit(10)
->page(2)
->get();
Constants::PERIOD_WEEK // Last 7 days
Constants::PERIOD_MONTH // Last month
Constants::PERIOD_3_MONTHS // Last 3 months
Constants::PERIOD_6_MONTHS // Last 6 months
Constants::PERIOD_YEAR // Last 12 months
Constants::PERIOD_OVERALL // All time