OAuth Encrypt Code > Token

#1

Hello,
I would like to use a POST method to create a BOT chat in PHP with the Oauth2 client of the developer platform but I can not do it.

Can you help me ?

<?php
$api_key = "<MY_API_KEY>";
$api_secret = "<MY_SECRET_KEY>"; 
 
function GetOAuthToken(){ 
    global $api_key,$api_secret;  
 
    $ch = curl_init("https://api.faceit.com/auth/v1/oauth/token");
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch, CURLOPT_POSTFIELDS, "grant_type=client_credentials");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
                                                "Content-Type:  application/json",
                                                "Authorization: Basic ".base64_encode($api_key.":".$api_secret)
                                            ));
 
    $result = CurlExecute($ch); 
    $result = json_decode($result);
    return $result->access_token;
}
?>