- Konu Yazar
- #1
PHP:
<?php
// Access token'ı buraya girin
$access_token = "your_access_token_here";
// API endpoint'ı
$endpoint = "https://api.spotify.com/v1/me/player/recently-played?limit=1";
// Header
$header = array(
"Authorization: Bearer " . $access_token,
);
// API'yi çağırın
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $endpoint,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => $header,
));
$response = curl_exec($curl);
curl_close($curl);
// Son dinlenen şarkının bilgilerini alın
$data = json_decode($response);
$track_name = $data->items[0]->track->name;
$artist_name = $data->items[0]->track->artists[0]->name;
$album_name = $data->items[0]->track->album->name;
$album_image = $data->items[0]->track->album->images[0]->url;
// HTML çıktısı oluşturun
echo '<div style="text-align: center;">';
echo '<img src="' . $album_image . '" alt="' . $album_name . '" style="width: 200px; height: 200px;">';
echo '<h3>' . $track_name . '</h3>';
echo '<p>' . $artist_name . ' - ' . $album_name . '</p>';
echo '</div>';
?>