Hello! I need to write a script that would call for Apple Music Api and return the data in JSON format. I have written a code, which I cannot execute, since it always gives me an error 404 Page not Found, thus I cannot even test this code whether or not it works.
I have obtained developer account and have all the keys that are needed, lmk if you need to see them. Could you take a look at this code and tell me what is wrong or whether or not it will work? If it won’t work, could you tell me how to fix it? Here is the Code:
<?php
require_once "vendom/autoload.php";
use \Firebase\JWT\JWT;
$apiKey = "...";
$teamId = "...";
$albumId = "...";
$header = [
"alg" => "ES256",
"kid" => $apiKey
];
$payLoad = [
"iss" => $teamId,
"kid" => $apiKey
];
$jwt = JWT::encode($payLoad, $apiKey, "ES256", null, $header);
$curl = curl_init();
curl_setpot_array(
$curl, array (
CURLOPT_URL => "...",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXEDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_CUSTOMEREQUEST => "GET",
CURLOPT_HTTPHEADER => array (
"Authorization: Bearer ".$jwt,
"Music-User_token: ",$musicUserToken
),
)
);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error#:" . $err;
} else {
echo $response;
}
?>