function getAccessToken($pix_url_auth, $arq_certificado, $client_id, $client_secret)
{
/
# Esta rotina consome um endpoid POST da Gerencianet para realizar a geração do AccessToken
/
$curl = curl_init();
$authorization = base64_encode("$client_id:$client_secret");
curl_setopt_array($curl, array(
CURLOPT_URL => $pix_url_auth, // Rota base, desenvolvimento ou produção
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"grant_type": "client_credentials"}',
CURLOPT_SSLCERT => $arq_certificado, // Caminho do certificado
CURLOPT_SSLCERTPASSWD => "",
CURLOPT_HTTPHEADER => array(
"Authorization: Basic $authorization",
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
curl_close($curl);
return json_decode($response, true);
}