a package for work with api chat-api.com
- PHP 7.1+ (with enabled cURL)
- Composer
Run this command in console:
composer require leRisen/whatsapp
/*
'https://foo.chat-api.com/' - api url,
`qwerty` - token
*/
$api = new \leRisen\WhatsApp\WhatsAppApiClient('https://foo.chat-api.com/', 'qwerty');
$request = $api->messagesList();
$request->setErrorHandler(function ($error) {
var_dump($error);
});
$request->setSuccessHandler(function ($result) {
var_dump($result);
});
$request->execute();
setApiUrl($url)
$url
(string)- return
self
Example:
$api->setApiUrl('https://foo.chat-api.com/');
setToken($key)
$key
(string)- return
self
Example:
$api->setToken('qwerty');
getApiUrl()
- return
string
Example:
$api->getApiUrl(); // https://foo.chat-api.com/
getToken()
- return
string
Example:
$api->getToken(); // qwerty
$api->getStatus();
- return
WhatsAppApiRequest
$api->getQrCode();
- return
WhatsAppApiRequest
$api->setWebHook($url);
- return
WhatsAppApiRequest
$api->getWebHook();
- return
WhatsAppApiRequest
$data = [
'phone': '79615238147',
'body': 'Hello, brother! 🍏',
];
$api->sendMessage($data);
$data
(array) - params (required)- return
WhatsAppApiRequest
$data = [
'chatId': '79615238147@c.us',
'body': 'https://upload.wikimedia.org/wikipedia/ru/3/33/NatureCover2001.jpg',
'filename': 'cover.jpg',
];
$api->sendFile($data);
$data
(array) - params (required)- return
WhatsAppApiRequest
$data = [
'lastMessageNumber' => 99,
];
$api->messagesList($data);
$data
(array) - params (required)- return
WhatsAppApiRequest
$api->showMessagesQueue();
- return
WhatsAppApiRequest
$api->clearMessagesQueue();
- return
WhatsAppApiRequest
$enable = true;
$api->notifications($enable);
- return
WhatsAppApiRequest
$api->logout();
- return
WhatsAppApiRequest
$api->logout();
- return
WhatsAppApiRequest