What are common issues when using the chatwoot API with PHP, specifically regarding authentication?
Common issues when using the Chatwoot API with PHP, specifically regarding authentication, include incorrect authentication headers or missing API keys. To solve this, ensure that the API key is correctly included in the request headers.
<?php
$api_key = 'YOUR_API_KEY';
$base_url = 'https://your-chatwoot-url.com/api/v1/';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $base_url . 'conversations');
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Api-Key: ' . $api_key
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>