1. Go to this page and download the library: Download sourceout/lastfm-php-sdk 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/ */
sourceout / lastfm-php-sdk example snippets
use Sourceout\LastFm\ProviderInterface;
use Sourceout\LastFm\Client as LastFmClient;
use Sourceout\LastFm\Provider\LastFm\LastFm;
/** @var ProviderInterface $provider */
$provider = new LastFm(['api_key' => 'your_api_key_here']);
/** @var LastFmClient $lastFmClient */
$lastFmClient = new LastFmClient();
/** @var Collection $topArtists */
$topArtists = $lastFmClient
->getServiceFactory($provider)
->getGeoService()
->getTopArtists(
'united states', // location
1, // page number
50 // results per page
);
use Sourceout\LastFm\Client as LastFmClient;
$lastFmClient = new LastFmClient();
$lastFmClient->registerCustomProviders(
[
\path\to\custom\provider::class
...
...
]
);
use Sourceout\LastFm\Http\Http;
use Sourceout\LastFm\Http\HttpInterface;
use Sourceout\LastFm\Client as LastFmClient;
use Http\Adapter\Guzzle6\Client as GuzzleClient;
use Http\Message\MessageFactory\GuzzleMessageFactory;
/** @var HttpInterface $http */
$http = new Http();
$http->setHttpClient(new GuzzleClient());
$http->setMessageFactory(new GuzzleMessageFactory());
/** @var LastFmClient $lastFmClient */
$lastFmClient = new LastFmClient($http);
use Sourceout\LastFm\Http\Http;
use Sourceout\LastFm\Http\HttpInterface;
use Sourceout\LastFm\Client as LastFmClient;
use Http\Adapter\Guzzle6\Client as GuzzleClient;
use Http\Message\MessageFactory\GuzzleMessageFactory;
/** @var HttpInterface $http */
$http = new Http();
$http->setHttpClient(new GuzzleClient());
$http->setMessageFactory(new GuzzleMessageFactory());
/** @var LastFmClient $lastFmClient */
$lastFmClient = new LastFmClient();
$lastFmClient->setHttpClient($http);
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.