All Projects β†’ barryvanveen β†’ lastfm

barryvanveen / lastfm

Licence: MIT license
🎢 Last.fm API client for PHP. Comes with a Laravel service provider.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to lastfm

vinyl-shelf-finder
app that manages a Discogs.com user records collection
Stars: ✭ 41 (+141.18%)
Mutual labels:  lastfm, lastfm-api
nicholast.fm
Last.fm Stat Utility Web App
Stars: ✭ 17 (+0%)
Mutual labels:  lastfm, lastfm-api
miso-bot
Discord bot with too many features
Stars: ✭ 41 (+141.18%)
Mutual labels:  lastfm, lastfm-api
MusaicFM
Screensaver inspired by Apple’s inbuilt iTunes Screensaver. It can display Artwork by Spotify or last.fm Profile Data.
Stars: ✭ 223 (+1211.76%)
Mutual labels:  lastfm, lastfm-api
music-screen-api
Display the playing Sonos track in real time on an e-ink display - also includes functionality for last.fm
Stars: ✭ 88 (+417.65%)
Mutual labels:  lastfm, lastfm-api
meituan-pub-union
🌈 ηΎŽε›’εˆ†ι”€θ”η›Ÿ PHP-SDK
Stars: ✭ 19 (+11.76%)
Mutual labels:  laravel-package
rescrobbled
MPRIS music scrobbler daemon
Stars: ✭ 152 (+794.12%)
Mutual labels:  lastfm
laravel-coming-soon
Laravel package to display Coming Soon page
Stars: ✭ 19 (+11.76%)
Mutual labels:  laravel-package
laravel-spotify
Laravel-Spotify is a simple wrapper around the Spotify Web API that makes working with its endpoints a breeze!
Stars: ✭ 141 (+729.41%)
Mutual labels:  laravel-package
laravel-snowflake
This Laravel package to generate 64 bit identifier like the snowflake within Twitter.
Stars: ✭ 94 (+452.94%)
Mutual labels:  laravel-package
xspfy
Import XSPF playlists to Spotify.
Stars: ✭ 29 (+70.59%)
Mutual labels:  lastfm
simple-recaptcha-v3
πŸ€– This repository contains simple reCAPTCHA v3 integration for your Laravel application.
Stars: ✭ 25 (+47.06%)
Mutual labels:  laravel-package
aliyun-oss-laravel
Laravel ηš„ Aliyun OSS 扩展, ζ”―ζŒ Laravel 9. Alibaba Cloud Object Storage Service For Laravel.
Stars: ✭ 91 (+435.29%)
Mutual labels:  laravel-package
laravel-helper-functions
Laravel-specific and pure PHP Helper Functions.
Stars: ✭ 106 (+523.53%)
Mutual labels:  laravel-package
voyager-page-blocks
A module to provide page blocks for Voyager πŸ“
Stars: ✭ 80 (+370.59%)
Mutual labels:  laravel-package
laravel-secureheaders
πŸ”’ SecureHeaders wrapper for Laravel.
Stars: ✭ 52 (+205.88%)
Mutual labels:  laravel-package
laracash
PHP Laravel Money Package πŸ’°
Stars: ✭ 52 (+205.88%)
Mutual labels:  laravel-package
laravel-smart-facades
Strategy design pattern in laravel, the easiest way.
Stars: ✭ 84 (+394.12%)
Mutual labels:  laravel-package
firebase-php
Firebase Realtime Database PHP Wrapper
Stars: ✭ 41 (+141.18%)
Mutual labels:  laravel-package
apitest
this is a tool for testing Laravel REST API
Stars: ✭ 11 (-35.29%)
Mutual labels:  laravel-package

Last.fm API client for PHP 8

Latest Version on Packagist Software License Total Downloads

API keys

You can create a last.fm API account at http://www.last.fm/api/account/create.

Installation

Via Composer

$ composer require barryvanveen/lastfm

Laravel installation

Add a LASTFM_API_KEY variable to your .env configuration. You could also publish the default configuration and alter it yourself:

php  artisan vendor:publish --provider="Barryvanveen\Lastfm\LastfmServiceProvider"

Update config/app.php by adding the LastfmServiceProvider:

'providers' => [
    ...
    Barryvanveen\Lastfm\LastfmServiceProvider::class,
];

If you are using Laravel 5.5 or higher, the service provider will be detected automagically by Laravel's package discovery.

Tested against Laravel 5.* but probably works in most versions because it is so simple. Please create an issue if it doesn't work for you.

Usage

Basic example

use Barryvanveen\Lastfm\Lastfm;
use GuzzleHttp\Client;
 
$lastfm = new Lastfm(new Client(), 'YourApiKey');
    
$albums = $lastfm->userTopAlbums('AnyUsername')->get();

Laravel example

use Barryvanveen\Lastfm\Lastfm;
 
public function index(Lastfm $lastfm)
{
    $albums = $lastfm->userTopAlbums('AnyUsername')->get();
    
    return view('home', compact('albums'));
}

All available methods

// Get top albums for user
$albums = $lastfm->userTopAlbums('AnyUsername')->get();
 
// Get top artists for user
$artists = $lastfm->userTopArtists('AnyUsername')->get();
 
// Get recent tracks for user
$tracks = $lastfm->userRecentTracks('AnyUsername')->get();
 
// Get user info
$info = $lastfm->userInfo('AnyUsername')->get();
 
// Get track that user is now listening to, or FALSE
$trackOrFalse = $lastfm->nowListening('AnyUsername'); 
 
// Get the weekly top albums given a starting day 
$albums = $lastfm->userWeeklyTopAlbums('AnyUsername', new \DateTime('2017-01-01'));                      
 
// Get the weekly top artists given a starting day 
$artists = $lastfm->userWeeklyTopArtists('AnyUsername', new \DateTime('2017-01-01'));
 
// Get the weekly top tracks given a starting day 
$tracks = $lastfm->userWeeklyTopTracks('AnyUsername', new \DateTime('2017-01-01'));

Filtering results

// Define time period for results
$lastfm->userTopAlbums('AnyUsername')
       ->period(Barryvanveen\Lastfm\Constants::PERIOD_WEEK)
       ->get();
                  
// Limit number of results
$lastfm->userTopAlbums('AnyUsername')
       ->limit(5)
       ->get();     
                 
// Retrieve paginated results
$lastfm->userTopAlbums('AnyUsername')
       ->limit(5)
       ->page(2)
       ->get();     

Valid time periods

// use these constants as an argument to ->period()
Barryvanveen\Lastfm\Constants::PERIOD_WEEK     = '7day';
Barryvanveen\Lastfm\Constants::PERIOD_MONTH    = '1month';
Barryvanveen\Lastfm\Constants::PERIOD_3_MONTHS = '3month';
Barryvanveen\Lastfm\Constants::PERIOD_6_MONTHS = '6month';
Barryvanveen\Lastfm\Constants::PERIOD_YEAR     = '12month';
Barryvanveen\Lastfm\Constants::PERIOD_OVERALL  = 'overall';

Official API docs

Read the official API documentation at http://www.last.fm/api.

Change log

Please see CHANGELOG for more information what has changed recently.

Testing

Copy phpunit.xml.dist to phpunit.xml. Then run the tests using:

$ composer test

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].