Status: development You can use it just to develop on it
WhatsAPI is a client library to use Whatsapp services.
This is a new project based on the original WhatsAPI: Please see the original project
The original WhatsAPI library is not compatible with composer, no PSR compatible, and it's very old. I want to develop this new library in order to make it more usable. If you want to help, just do it :)
Just an example:
- The client received a message.
- It's converted in a
Nodeobject, if exists could be a specificNodeobject, likeSuccessnode. - One or more default listeners are attached to the
node.receivedevent. There are also specific event for each tag node. They do all the internal things, like response to system messages. - Anyone can create a listener to do something on a certain event, like message received, presence changed, etc.
The library is not complete, you can just login and instantiate the first connection.
$number = ''; // your number
$token = ''; // token
$nickname = ''; // your name
$password = ''; // your password
$client = new \WhatsAPI\Client\Client($number, $token, $nickname);
$client->getEventManager()->attach('*', function (\Zend\EventManager\EventInterface $e) {
if ($e instanceof \WhatsAPI\Message\Event\NodeEvent) {
echo $e->getName() . PHP_EOL;
echo $e->getNode() . PHP_EOL;
return;
}
});
$client->connect();
$client->loginWithPassword($password);
while (true) {
$client->pollMessages();
}