Configuration
$baseUrl = 'https://evoapi.faisak.com';
$apiKey = 'wg_live_replace_with_your_key';
On-Site Documentation
Plain PHP examples for sending messages and verifying customer webhooks.
PHP
SDK examples are available now. Official package releases are being prepared.
$baseUrl = 'https://evoapi.faisak.com';
$apiKey = 'wg_live_replace_with_your_key';
$payload = [
'instance_id' => 'demo-support-line',
'phone' => '+9665XXXXXXX',
'message' => 'Your order has shipped.',
'message_purpose' => 'transactional',
];
$ch = curl_init($baseUrl . '/api/send-message');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode($payload, JSON_UNESCAPED_SLASHES),
]);
$rawResponse = curl_exec($ch);
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$json = json_decode((string) $rawResponse, true);
Use transactional, operational, support, internal_team, or authentication. Marketing, cold outreach, and bulk campaigns are not allowed.
if (!is_array($json) || ($json['success'] ?? false) !== true) {
$errorCode = (string) ($json['error'] ?? 'unknown_error');
$message = (string) ($json['message'] ?? 'Request failed.');
// Common examples:
// module_not_enabled, message_purpose_not_allowed,
// recipient_suppressed, sending_throttled
throw new RuntimeException($errorCode . ': ' . $message);
}
$secret = 'replace_with_webhook_signing_secret';
$timestamp = $_SERVER['HTTP_X_WHATSAPP_GATEWAY_TIMESTAMP'] ?? '';
$signature = $_SERVER['HTTP_X_WHATSAPP_GATEWAY_SIGNATURE'] ?? '';
$rawBody = file_get_contents('php://input') ?: '';
$expected = 'sha256=' . hash_hmac('sha256', $timestamp . '.' . $rawBody, $secret);
if (!hash_equals($expected, $signature)) {
http_response_code(401);
exit('Invalid signature');
}
$event = json_decode($rawBody, true);
$eventName = (string) ($event['event'] ?? '');
switch ($eventName) {
case 'message.received':
// Read $event['from'], $event['message_text'], and $event['timestamp'].
break;
case 'recipient.opted_out':
// Mark $event['from'] as opted out in your application.
break;
case 'message.sent':
case 'message.failed':
// Update local message status using message_id or your own correlation data.
break;
}
http_response_code(200);
echo 'ok';