![Avatar discord do usuario alissonmaciel_32335](https://cdn.discordapp.com/embed/avatars/0.png)
E na minha requisição pra criar o webhook, ainda estou recebendo essa mensagem de erro:
string(102) "{"nome":"webhook_invalido","mensagem":"A requisição na URL informada falhou com o erro: ECONNRESET"}"
No meu arquivo webhook.php eu coloquei pra criar um TXT do que é recebido e recebo isto:
{
"evento": "teste_webhook",
"data_criacao": "2024-05-09T15:13:32.178Z"
}
Ok, no $body insira o ?ignorar=
$body = '{
"webhookUrl": "https://julioerp.agenciaweblab.com.br/webhook.php?ignorar="
}';
E no arquivo "/webhook.php" inseira o exemplo de código abaixo:
' . json_encode($resposta, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . '';
string(102) "{"nome":"webhook_invalido","mensagem":"A requisição na URL informada falhou com o erro: ECONNRESET"}"
Troque o type "Basic" para "Bearer", assim: $headers[] = 'Authorization: Bearer ' . $this->access_token;
Meu Webhook: public function webhook() {
$body = '{
"webhookUrl": "https://julioerp.agenciaweblab.com.br/webhook.php"
}';
try {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->config['rotas'] . '/v2/webhook/' . $this->config['chave_pix']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_SSLCERT, $this->config["certificado"]);
curl_setopt($ch, CURLOPT_SSLCERTPASSWD, '');
$headers = array();
$headers[] = 'Authorization: Basic ' . $this->access_token;
$headers[] = 'X-Skip-Mtls-Checking: true';
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
echo '
';';
var_dump($this->config['chave_pix'], $this->config['client_id'], $this->config['client_secret'], $result);
echo '
';';
var_dump($e->getCode(), $e->getFile(), $e->getMessage());
echo '
string(78) "{"error":"invalid_token","error_description":"Malformed authorization header"}"
@alissonmaciel_32335, troque no header o content_type para $headers[] = 'Content-Type: application/json';