PHP code example of salavati / wa-messenger

1. Go to this page and download the library: Download salavati/wa-messenger 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/ */

    

salavati / wa-messenger example snippets


use Salavati\WaMessenger\WaMessenger;

$waMessenger = new WaMessenger(env('WA_MESSENGER_API_KEY'));
// Or
$waMessenger = new WaMessenger();
$waMessenger->setApiKey(env('WA_MESSENGER_API_KEY'));

$waMessenger->setReceivers('989121234567'); // For single receiver
// Or
$phoneNumber = ['989121234567', '989121234568', ...]; // For multiple receivers.
$waMessenger->setReceivers($phoneNumber);

// For text message
$result = $waMessenger->sendMessage($text)

// For file message
$result = $waMessenger->sendMessage($caption, $fileUrl)