PHP code example of core23 / lastfm-api

1. Go to this page and download the library: Download core23/lastfm-api 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/ */

    

core23 / lastfm-api example snippets


// Create connection
use Nucleos\LastFm\Service\AuthService;
use Nucleos\LastFm\Service\ChartService;
use Nucleos\LastFm\Service\PsrClientConnection;

$connection = new PsrClientConnection($httpClient, $requestFactory);

// Auth user to get a token
// http://www.last.fm/api/auth/?api_key=API_KEY

// Create a session (with generated token)
$token = 'API token';
$authApi = new AuthService($connection);
$session = $authApi->createSession($token);

$chartApi = new ChartService($connection);
$tags = $chartApi->getTopTags(10);