Bom dia!
Estou com dificuldades de gerar boleto com PHP Curl. Sempre retorna: Unauthorized.
Utilizei credencias de Homologação.
Estou utilizando esse modelo:
$config = [
"client_id" => "Client_Id_....",
"client_secret" => "Client_Secret_...."
];
$autorizacao = base64_encode($config["client_id"] . ":" . $config["client_secret"]);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://cobrancas-h.api.efipay.com.br/v1/charge/one-step',
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 =>'{
"items": [{
"name": "Product 1",
"value": 500,
"amount": 1
}],
"shippings": [{
"name": "Default Shipping Cost",
"value": 100
}],
"payment": {
"banking_billet": {
"expire_at": "2024-04-16",
"customer": {
"name": "Gorbadoc Oldbuck",
"email": "[email protected]",
"cpf": "10617184682",
"birth": "1977-01-15",
"phone_number": "62986070247"
}
}
}
}',
CURLOPT_HTTPHEADER => array(
"Authorization: Basic $autorizacao",
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;