PHP code example of bluedot-bd / laravel-bulk-sms

1. Go to this page and download the library: Download bluedot-bd/laravel-bulk-sms 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/ */

    

bluedot-bd / laravel-bulk-sms example snippets


use LaravelBulksms;
$sms = new LaravelBulksms(); // config name not needed
$params = [
    'api_mode'         => 'dry', // dry/live
    'send_method'      => 'GET', // GET/POST
    'send_url'         => '',
    'send_header'      => '', // Comma separated header
    'send_success'     => '', // valid regex or empty (without delimiter)
    'send_error'       => '', // valid regex or empty (without delimiter)
    'balance_url'      => '',
    'balance_method'   => '', // GET/POST
    'balance_header'   => '', // Comma separated header
    'balance_key'      => '', // json object key
];
$config = 'smsdone'; // any name you want, this will be your config file name
$url = ''; // your api url with all params
try {
    $sms->checkAndSave($params, $url, $config);
} catch (Exception $e) {
    // Get Error from Exception
    // If you get this error, create a issue with your api url (please remove any api key or password)
}


use LaravelBulksms;
use BluedotBd\LaravelBulksms\SmsChannel;

public function via($notifiable)
{
    return [SmsChannel::class];
}

/**
 * Get the sms representation of the notification.
 *
 * @param  mixed  $notifiable
 */
public function toSms($notifiable)
{
    return (new LaravelBulksms("config_file_name"))
        ->to()
        ->line();
}

use LaravelBulksms;
$sms = new LaravelBulksms("config_file_name");
try {
    $sms->to('01xxxx')->message('Your SMS Text')->send();   
} catch (Exception $e) {
    // SMS Sending Error
}

dispatch(new BluedotBd\LaravelBulksms\Jobs\SendSMS($config,$number, $message));
// or
dispatch((new BluedotBd\LaravelBulksms\Jobs\SendSMS($config,$number, $message))->onQueue('high'));
// or
dispatch((new BluedotBd\LaravelBulksms\Jobs\SendSMS($config,$number, $message))->delay(60));

use LaravelBulksms;
$sms = new LaravelBulksms("config_file_name");
$sms->balance(); // returns float