'client_credentials' ])); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Basic ' . base64_encode("$client_id:$client_secret"), 'Content-Type: application/x-www-form-urlencoded' ]); $response = curl_exec($ch); curl_close($ch); $data = json_decode($response, true); return $data['access_token']; } function getTrackInfo($url) { $accessToken = getSpotifyAccessToken(); $trackId = basename(parse_url($url, PHP_URL_PATH)); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://api.spotify.com/v1/tracks/$trackId"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer ' . $accessToken ]); $response = curl_exec($ch); curl_close($ch); return json_decode($response, true); } function getDistributor($isrcCode) { $distributors = [ 'QZNWY' => 'DistroKid', 'SE5XG' => 'Amuse', 'QZYFZ' => 'Revelator', 'GBMOR' => 'The Orchard', 'USMOR' => 'The Orchard', 'NLFUG' => 'Fuga', 'SEFUG' => 'Fuga', 'NGB5S' => 'Yivera Music' ]; foreach ($distributors as $prefix => $distributor) { if (strpos($isrcCode, $prefix) === 0) { return $distributor; } } return 'Bilinmeyen'; } $trackInfo = null; $distributor = null; if ($_SERVER["REQUEST_METHOD"] == "POST" && !empty($_POST['spotify_url'])) { $url = $_POST['spotify_url']; $trackInfo = getTrackInfo($url); $isrcCode = $trackInfo['external_ids']['isrc'] ?? null; if ($isrcCode) { $distributor = getDistributor($isrcCode); } } ?>
Şarkı Adı | |
---|---|
Sanatçı | |
Albüm | |
ISRC Kodu | |
Dağıtıcı |