New API rules breaking old script, help

Thanks @BarryCarlyon, that’s really helpful.

And thanks for your patience with my newbie questions.

So, in terms of generating the token - most of the docs are covering authenticating users or accessing user data, I don’t need to do any of that - so I’m unsure what the bare minimum ‘stuff’ is that I need there. Tested this, but throws 401. Do you guys see something I’m missing?

$ch = curl_init("https://id.twitch.tv/oauth2/authorize");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$fields = array(
    'client_id' => 'Client-ID: p8li1rfpjyvhm1626h00ame4ccfh22',
    'client_secret' => 'xxxxxxxxxxxxxxxxx',
    'response_type' => 'token',
    'token_type' => 'bearer',
    'redirect_uri' => 'http://localhost/php/twitch.php',
    'state' => $_POST['state']
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
$data = curl_exec($ch);


print_r($data); 
$info = curl_getinfo($ch); 

echo '<pre>';
print_r($info);
echo '</pre>';