PHP code example of octopusteam / waapi-laravel

1. Go to this page and download the library: Download octopusteam/waapi-laravel 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/ */

    

octopusteam / waapi-laravel example snippets


use OctopusTeam\Waapi\Facades\Waapi;

// Send a simple text message
Waapi::sendMessage('201xxxxxxxxx', 'Hello, world!');

// Send an OTP with custom message
$otp = Waapi::generateOtp();
Waapi::sendOtp('201xxxxxxxxx', $otp, false, false, ":otp is your verification code.");

// Send Media (File)
Waapi::sendMedia('201xxxxxxxxx', 'Here is your invoice', 'https://example.com/invoice.pdf');

// Send Template
Waapi::sendTemplate('201xxxxxxxxx', 'template_id', [
    'variables[{1}]' => 'Value 1',
    'variables[{2}]' => 'Value 2'
]);

// Send Sticker
Waapi::sendSticker('201xxxxxxxxx', 'https://example.com/sticker.webp');

// Send Voice Note
Waapi::sendVoice('201xxxxxxxxx', 'https://example.com/voice.mp3');

// Send Location
Waapi::sendLocation('201xxxxxxxxx', '30.0444', '31.2357');

// Send Contact
Waapi::sendContact('201xxxxxxxxx', 'John Doe', '201xxxxxxxxx', 'Octopus Team');

// Send Conversation Message
Waapi::sendConversationMessage('201xxxxxxxxx', 'Hello from conversation');

// Get Device Status
$status = Waapi::getDeviceStatus('device_id');

// Get QR Code
$qr = Waapi::getQrCode('device_id');

// Get single message status
$status = Waapi::getMessageStatus('message_id');

// Get multiple messages status
$status = Waapi::getMessagesStatus(['id1', 'id2', 'id3']);

// Get all devices
$devices = Waapi::getDevices();

// Create a new device
$device = Waapi::createDevice('New Device Name', 'https://webhook.site/...');

// Get a specific device
$device = Waapi::getDevice('device_id');

// Update a device
$updated = Waapi::updateDevice('device_id', 'Updated Name', 'https://webhook.site/...');

// Delete a device
$deleted = Waapi::deleteDevice('device_id');

// Get all apps
$apps = Waapi::getApps();

// Create a new app
$app = Waapi::createApp('App Name', 'device_id', 'https://example.com');

// Get a specific app
$app = Waapi::getApp('app_id');

// Delete an app
$deleted = Waapi::deleteApp('app_id');

// Check contact presence on WhatsApp
$presence = Waapi::contactPresence('device_id', '201xxxxxxxxx');

// Get Profile Pictures (batch)
$pictures = Waapi::getProfilePictures(['201xxxxxxxxx', '201yyyyyyyyy'], 'device_id');

// Get current webhook settings
$settings = Waapi::getWebhookSettings();

// Update webhook settings
$updated = Waapi::updateWebhookSettings('https://example.com/webhook');

'webhook' => [
    'enabled' => true,
    'auto_register' => true,
],

use OctopusTeam\Waapi\Events\WebhookReceived;

protected $listen = [
    WebhookReceived::class => [
        SendEmailNotification::class,
    ],
];

// Get the last 50 requests from Webhook.site
$data = Waapi::getWebhookSiteData(50);

// Get the decoded content from the last 50 requests
$content = Waapi::getWebhookSiteContent(50);

// Get a specific request by its ID
$request = Waapi::getWebhookSiteRequest('request-uuid');
bash
php artisan vendor:publish --provider="OctopusTeam\Waapi\WaapiServiceProvider"
bash
php artisan waapi:webhook-renew