PHP code example of marvelley / lastfm-api
1. Go to this page and download the library: Download marvelley/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/ */
marvelley / lastfm-api example snippets
use Marvelley\Lastfm\Api\LastfmApiClient;
$l = LastfmApiClient::factory(array('api_key' => 'your_api_key'));
$ai = $l->getCommand('artist.getInfo', array(
'artist' => 'Elvis Presley',
"format" => "json"
));
$result = $ai->execute();
echo "Similar artists:\n";
foreach($result['artist']['similar']['artist'] as $artist) {
printf(" - %s\n", $artist['name']);
}
$ export LAST_FM_PHP_CLIENT_API_KEY=your_api_key