scottcarlson / PHP-Last.fm-API

PHP Last.fm API is a set of classes which help you gain access to Last.fm's API using PHP. It allows you to get information on users, artists, albums, tracks, groups, events and tags. It also contains geographic API classes to get musical geo information

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PHP Last.FM API

Thank you for using PHP Last.FM API!

You will need your own API key by registering at: http://www.last.fm/api

Installation

composer require matto1990/lastfm-api

Usage

use LastFmApi\Api\AuthApi;
use LastFmApi\Api\ArtistApi;

class LastFm
{
    private $apiKey;
    private $artistApi;

    public function __construct()
    {
        $this->apiKey = 'apikeyfromlastfm'; //required
        $auth = new AuthApi('setsession', array('apiKey' => $this->apiKey));
        $this->artistApi = new ArtistApi($auth);
    }
    public function getBio($artist)
    {
        $artistInfo = $this->artistApi->getInfo(array("artist" => $artist));

        return $artistInfo['bio'];
    }	
}

Testing

To run phpunit successfully, a .env file must be included in tests/Api:

lastfm_api_key=
lastfm_api_secret=
lastfm_token=
lastfm_session_key=
lastfm_username=

About

PHP Last.fm API is a set of classes which help you gain access to Last.fm's API using PHP. It allows you to get information on users, artists, albums, tracks, groups, events and tags. It also contains geographic API classes to get musical geo information

License:MIT License


Languages

Language:PHP 100.0%