jfhovinne / phplastfm
This package is abandoned and no longer maintained.
No replacement package was suggested.
Last.fm API client
dev-master
2015-12-26 18:10 UTC
Requires
- php: >=5.5.0
- guzzlehttp/guzzle: ^6.1
This package is not auto-updated.
Last update: 2020-08-26 00:03:14 UTC
README
Last.fm PHP client
Install
$ composer require jfhovinne/phplastfm:dev-master
Use
First get a Last.fm API key, see http://www.last.fm/api
Then, instantiate the client by passing the API key:
<?php
require __DIR__ . '/vendor/autoload.php';
use Lastfm\Client as LastfmClient;
$lastfmclient = new LastfmClient('your_api_key');
To call a Last.fm API method and get the results in JSON, use callMethod($methodName, $parameters)
.
$json = $lastfmclient->callMethod('user.getTopTracks', ['user' => 'lastfm_username', 'limit' => '20']);
if (isset($json->error)) {
echo($json->message);
} else {
foreach($json->toptracks->track as $track) {
echo($track->artist->name . ' - ' . $track->name . "\n");
}
}