chrismou / lastfm
A simple but fully featured Last.fm API wrapper, with Guzzle 6 support
Installs: 1 156
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 1
Requires
- php: >=5.5
- guzzlehttp/guzzle: ~6.0
Requires (Dev)
- codeclimate/php-test-reporter: dev-master
- mockery/mockery: ~0.9
- phpunit/phpunit: ~4.0
- squizlabs/php_codesniffer: *
- vectorface/dunit: ^2.1
This package is auto-updated.
Last update: 2024-12-12 04:18:26 UTC
README
A dead simple wrapper class for the last.fm API. After using a couple of existing last.fm wrapper classes, it became obvious that most were either a) Incomplete, b) Seemingly abandoned, or c) Poorly unit tested. After the August 2015 last.fm redesign, the library I'd settled with started throwing unexepected errors. At this point, I decided it might be simpler to just write my own.
This library aims to address these issues, providing a simple, centralised way of calling any method on the last.fm API, meaning it should support all future API additions out of the box. It also includes an full set of unit tests.
Install
For composer based projects:
composer require chrismou/lastfm
Usage
First you need an API key and secret from Last.FM. You can obtain one by signing up here: http://www.last.fm/api
To set up the last.fm API client:
$lastfm = new \Chrismou\LastFm\LastFm(
new GuzzleHttp\Client(),
YOUR_API_KEY,
YOUR_API_SECRET
);
The format for calls is: $lastfm->get($method, $parameters);
, where method is the last.fm api method name.
So, if you wanted to get info on an artist, you could run:
$lastfm->get('artist.getInfo', 'cher');
This makes a request and returns all info on the Artist 'Cher'.
Please refer to the last.fm api documentation for a full list of available methods and required parameters.
Tests
To run the unit test suite:
curl -s https://getcomposer.org/installer | php
php composer.phar install
./vendor/bin/phpunit
If you use docker, you can also run the test suite against all supported PHP versions:
./vendor/bin/dunit
License
Released under the MIT License. See LICENSE.
Thanks to
dandelionmood/php-lastfm, the original inspiration for the library.