You didn’t set CURLOPT_RETURNTRANSFER as a curl_setopt
So $res as basic true/false on did curl die or not
This PHP example may help https://github.com/BarryCarlyon/twitch_misc/blob/main/authentication/user_access_generator/php/maintain_user_token.php#L21