API Request does not work anymore!

This is just the generator function, not your API calling function need the whole thing really…

You are putting the keys into $token when you should be using $keys.
Since if the $keys (loaded from the JSON file) are valid then it won’t make a $token.

So $token = json_decode($r); should be $keys = json_decode($r);

And the oAuth header in your code/call to the API should be

curl_setopt_array($ch3, array(
CURLOPT_HTTPHEADER => array(
'Client-ID: ’ . $clientId,
'Authorization: Bearer ' . $keys['access_token']
),