1. Go to this page and download the library: Download waapi/waapi-laravel-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use App\Listeners\WaAPIInstanceReadyListener;
use App\Listeners\WaAPIMessageListener;
use WaAPI\WaAPI\Events\MessageEvent;
use WaAPI\WaAPI\Events\QrEvent;
[...]
protected $listen = [
MessageEvent::class => [
WaAPIMessageListener::class,
],
QrEvent::class => [
WaAPIQrCodeListener::class,
],
];
namespace App\Listeners;
use WaAPI\WaAPI\Events\MessageEvent;
use WaAPI\WaAPI\WaAPI;
class WaAPIMessageListener
{
/**
* Handle the event.
*/
public function handle(MessageEvent $message): void
{
if (!$message->isFromMe()) {
app(WaAPI::class)->sendMessage($message->getFrom(), 'Hello to you too!');
}
}
}