1. Go to this page and download the library: Download elbrahms/wa-gateway 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/ */
elbrahms / wa-gateway example snippets
use Elbrahms\WaGateway\Facades\WaGateway;
// Send a text message
WaGateway::sendMessage('22799123456', 'Hello from Laravel!');
// Send an image
WaGateway::sendMedia('22799123456', 'image', 'https://example.com/photo.jpg', 'Check this out!');
// Send a document
WaGateway::sendMedia('22799123456', 'document', 'https://example.com/report.pdf');
// Send a poll
WaGateway::sendPoll('22799123456', 'Favourite color?', ['Red', 'Blue', 'Green']);
// Send a sticker
WaGateway::sendSticker('22799123456', 'https://example.com/sticker.webp');
// Send a location
WaGateway::sendLocation('22799123456', '13.5137', '2.1098');
// Send a vCard
WaGateway::sendVcard('22799123456', 'Ibrahim Sidi', '22799000000');
// Check if a number is on WhatsApp
$result = WaGateway::checkNumber('22799123456');
// $result['msg']['exists'] === true
// Generate QR code to connect a device
$qr = WaGateway::generateQr('22799749554');
// $qr['qrcode'] is a base64-encoded PNG — display or save it
// Create a new device
WaGateway::createDevice('22799000001', 'https://yourapp.com/webhook');
// Get device information
$info = WaGateway::deviceInfo('22799749554');
// Disconnect a device
WaGateway::disconnectDevice('22799749554');
// Create a user
WaGateway::createUser(
username: 'newuser',
password: 'secret123',
email: '[email protected]',
expire: 30,
limitDevice: 5
);
// Get user info
$user = WaGateway::userInfo('newuser');
use Elbrahms\WaGateway\WaGateway;
class NotificationService
{
public function __construct(protected WaGateway $wa) {}
public function notify(string $phone, string $text): void
{
$this->wa->sendMessage($phone, $text);
}
}