Update Twitch Channel

You might be right on the scope.

My understanding is you ONLY need the scope if you are updating someone else’s channel. If you are updating your own it should work without it. (But I don’t run code to update my own channel and this example is illustrative of what should work and should not be used in production)

Consider adapting

    if ($i['http_code'] == 200) {
        echo 'OK';
    } else {
        echo 'An Error Occured';
    }

to

    if ($i['http_code'] == 200) {
        echo 'OK';
    } else {
        echo 'An Error Occured ' . $i['http_code'] . ' - ' . $r;
    }

To spit out whatever the error is

I expect the issue is that

    curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode([
        'status' => $_POST['status'],
        'game' => $_POST['game']
    ]));

Should be, as I built the POST payload wrong.

    curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode([
        'channel' => [
            'status' => $_POST['status'],
            'game' => $_POST['game']
         ]
    ]));

Additionally:

    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        'Authorization: OAuth ' . $_SESSION['twitch']['access_token'],
        'Content-Type: application/json'
    ));

should be

    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        'Authorization: OAuth ' . $_SESSION['twitch']['access_token'],
        'Accept: application/vnd.twitchtv.v5+json',
        'Content-Type: application/json'
    ));