WhatsApp Business API
DecisionTelecom WhatsApp API позволяет отправлять и получать деловые сообщения WhatsApp в любую страну мира и из нее через API. Каждое сообщение идентифицируется уникальным случайным идентификатором, поэтому пользователи всегда могут проверить статус сообщения, используя заданную конечную точку.
WhatsApp API использует HTTPS с ключом доступа, который используется в качестве авторизации API. Полезные данные запросов и ответов форматируются как JSON с использованием кодировки UTF-8.
API Авторизация - Базовый ключ доступа Base64.
Чтобы получить ключ API, пожалуйста, свяжитесь с вашим менеджером по работе с клиентами.
Auth
Basic Auth
$userHashKey = 'User Hash Key provided by your account manager';
$ch = curl_init('https://web.it-decision.com/v1/api/send-whatsapp');
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "$userHashKey");
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($requestParams)); // $requestParams - raquest array with correct data
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$result = curl_exec($ch);
curl_close($ch);API Send WhatsApp message
source_addr:
<= 20 chars - from whom the message
destination_addr:
<= 20 chars - to whom the message
message_type:
Type of message to be sent:
1 text message
2 message with media data (jpg, jpeg or png images)
4 message based on registered template
text:
<= 4096 chars - text of WhatsApp message
file_url:
Correct URL with image for media message. Correct file extensions:
jpg or jpeg (mime type is image/jpeg)
png (mime type is image/png)
callback_url:
Correct URL for message status callback
template_name:
Registered template name (only for template message)
template_params:
JSON data of all the necessary parameters to send a template message.
message_id:
Sent message ID
API Receive WhatsApp message:
message_id:
The ID of the message whose status you want to get
message_id:
The ID of the message whose status you want to get
status:
Current WhatsApp message status
WhatsApp messages statuses
delivered
1
rejected
2
error
3
failed
4
deleted
5
pending
6
seen
7
Errors
message
Rate limit exceeded
code
0
status
429
message
Empty parameter or parameter validation error
code
1
status
4
message
The server encountered an unexpected condition which prevented it from fulfilling the request
code
2
status
500
message
User balance is empty
code
3
status
402
message
The server encountered an unexpected condition which prevented it from fulfilling the request
code
4, // 5 and 6
status
500
message
Message failed to send because more than 24 hours have passed since the customer last replied to this number. In this case, you can only send a template message
code
7
status
503
message
Invalid MIME type file_url
code
8
status
401
message
Invalid file extension
code
9
status
401
Примеры Отправки WhatsApp сообщений:
Last updated