Your curlopt_postfields is incorrectly formatted
See twitch_misc/authentication/app_access_tokens/php at main · BarryCarlyon/twitch_misc · GitHub for a PHP example
Should be an array like
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
'client_id' => CLIENT_ID,
'client_secret' => CLIENT_SECRET,
'grant_type' => "client_credentials"
));