PHP code example of snapshotpl / last-fm-client

1. Go to this page and download the library: Download snapshotpl/last-fm-client 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/ */

    

snapshotpl / last-fm-client example snippets




 = new LastFmClient\Auth();
$auth->setApiKey('your-api-key');
$auth->setSecret('your-secret');
$auth->setToken('user-token');
$auth->setSession('user-session');

$transport = new LastFmClient\Transport\Curl();

$client = new LastFmClient\Client($auth, $transport);

$trackService = new LastFmClient\Service\Track();
$trackService->setClient($client);

$response = $trackService->getInfo('Numb', 'Linkin Park');

var_dump($response->getData());

$client->call('resource.getAwesomeness', [], LastFmClient\Transport\TransportInterface::METHOD_GET);

$trackService->scrobble('Seven Lions', 'Days to Come', $timestamp);

$trackService->scrobbleBatch([
    [
        'artist' => 'Linkin Park',
        'track' => 'Numb',
        'timestamp' => time()-1000,
    ],
    [
        'artist' => 'Seven Lions',
        'track' => 'Days to Come',
        'timestamp' => time()-1200,
    ],
]);

$url = $client->getAuthUrl();
header('Location: '.$url);

$authService = LastFmClient\Service\Auth();
$authService->setClient($client);
$data = $authService->getSession()->getData();
var_dump($data);