API Request does not work anymore!

if(isset($_GET['post'])) {
define("CLIENT_ID", "xxx");
define("CLIENT_SECRET", "xxx");

$keys = false;
if (file_exists(__DIR__ . '/auth.json')) {
    $keys = json_decode(file_get_contents(__DIR__ . '/auth.json'));
}

$generate_token = true;
if ($keys) {
    // validate the token

    $ch99 = curl_init('https://id.twitch.tv/oauth2/validate');
    curl_setopt($ch99, CURLOPT_HTTPHEADER, array(
        'Authorization: OAuth ' . $keys->access_token //YOU SAID SOMETHING WRONG WITH THIS!!
    ));
    curl_setopt($ch99, CURLOPT_RETURNTRANSFER, true);

    $r = curl_exec($ch99);
    $i = curl_getinfo($ch99);
    curl_close($ch);

    if ($i['http_code'] == 200) {
        // the token appears good
        $generate_token = false;

        // optional to check the expires
        $token = json_decode($r);
        if (json_last_error() == JSON_ERROR_NONE) {
            if ($token->expires_in < 3600) {
                // less than an hour left
                // make a new token
                echo 'Token close to expire. Regenerate';
                $generate_token = true;
            }
        } else {
            echo 'Failed to parse JSON. Assume dead token';
            $generate_token = true;
        }
    }
}

if ($generate_token) {
    $ch99 = curl_init('https://id.twitch.tv/oauth2/token');
    curl_setopt($ch99, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch99, CURLOPT_POST, true);
    curl_setopt($ch99, CURLOPT_POSTFIELDS, array(
        'client_id' => CLIENT_ID,
        'client_secret' => CLIENT_SECRET,
        'grant_type' => "client_credentials"
    ));

    $r = curl_exec($ch99);
    $i = curl_getinfo($ch99);
    curl_close($ch99);

    if ($i['http_code'] == 200) {
        $token = json_decode($r);
        if (json_last_error() == JSON_ERROR_NONE) {
            echo 'Got token';
            print_r($token);

            // store the token for next run
            file_put_contents(__DIR__ . '/auth.json', $r, JSON_PRETTY_PRINT);
        } else {
            echo 'Failed to parse JSON';
        }
    } else {
        echo 'Failed with ' . $i['http_code'] . ' ' . $r;
    }
} else {
    echo 'Token OK'; echo "</br>"; echo "</br>";
    print_r($keys);
}

 $gameName = htmlspecialchars($_POST['name1']);
 $channelsApi3 = 'https://api.twitch.tv/helix/games?name=';
 $clientId = 'xxx';
 $ch3 = curl_init();
 $apiVers3 = '&api_version=5';
 $uri3 = '&redirect_uri=https://smartsblog.optimal-options.de/';
 
 curl_setopt_array($ch3, array(
    CURLOPT_HTTPHEADER => array(
       'Client-ID: ' . $clientId,
'Authorization: Bearer ' . $keys['access_token']
    ),
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_URL => $channelsApi3 . urlencode($gameName) . $apiVers3 . $uri3
 ));

 $response3 = curl_exec($ch3);