Skip to content

An unofficial API to interact with the service chat-api.com

License

Notifications You must be signed in to change notification settings

rahulyhg/whatsapp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WhatsApp forthebadge

Version License Last commit Downloads

a package for work with api chat-api.com

Table of Contents

Requirements

Install

Run this command in console:

composer require leRisen/whatsapp

Sample

/*
    '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();

Functions

Set api url

setApiUrl($url)
  • $url (string)
  • return self

Example:

$api->setApiUrl('https://foo.chat-api.com/');

Set token

setToken($key)
  • $key (string)
  • return self

Example:

$api->setToken('qwerty');

Get api url

getApiUrl()
  • return string

Example:

$api->getApiUrl(); // https://foo.chat-api.com/

Get token

getToken()
  • return string

Example:

$api->getToken(); // qwerty

Get account status and QR code for authorization

$api->getStatus();
  • return WhatsAppApiRequest

Direct link to the QR code as an image

$api->getQrCode();
  • return WhatsAppApiRequest

Set webhook

$api->setWebHook($url);
  • return WhatsAppApiRequest

Get webhook

$api->getWebHook();
  • return WhatsAppApiRequest

Send a message

$data = [
    'phone': '79615238147',
    'body': 'Hello, brother! 🍏',
];

$api->sendMessage($data);
  • $data (array) - params (required)
  • return WhatsAppApiRequest

Send a file

$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

Returns messages list

$data = [
    'lastMessageNumber' => 99,
];

$api->messagesList($data);
  • $data (array) - params (required)
  • return WhatsAppApiRequest

Show a list of messages that are queued for shipment but not yet sent

$api->showMessagesQueue();
  • return WhatsAppApiRequest

Clear the message queue.

$api->clearMessagesQueue();
  • return WhatsAppApiRequest

Enable or disable ack notifications

$enable = true;

$api->notifications($enable);
  • return WhatsAppApiRequest

Sign out and request a new QR code

$api->logout();
  • return WhatsAppApiRequest

Reload your WhatsApp instance

$api->logout();
  • return WhatsAppApiRequest

About

An unofficial API to interact with the service chat-api.com

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages