20 lines
521 B
PHP
20 lines
521 B
PHP
<?php
|
|
|
|
function getCoverOf($track_name)
|
|
{
|
|
$api_endpoint = 'https://api.deezer.com/2.0/search';
|
|
$search_parameters = array(
|
|
'q' => $track_name,
|
|
'output' => 'json',
|
|
'nb_items' => 1
|
|
);
|
|
$search_uri = $api_endpoint
|
|
.'?'
|
|
.http_build_query($search_parameters);
|
|
|
|
$track = json_decode(file_get_contents($search_uri));
|
|
|
|
return empty($track->data)
|
|
?: $track->data[0]->album->cover;
|
|
}
|