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 BluedotBd\LaravelBulksms\LaravelBulksms;

$url = 'https://api.smsd.one/sendtext?apikey=YOUR_KEY&callerID=LKEY'
     . '&toUser=8801700000000&messageContent=hello';

$saved = (new LaravelBulksms())->checkAndSave([
    'api_mode'       => 'dry',     // dry = log the request, live = call the gateway
    'send_method'    => 'GET',     // GET or POST
    'send_url'       => $url,
    'send_header'    => '',        // comma separated request headers
    'send_success'   => '',        // regex for "sent", e.g. 'status.*success'
    'send_error'     => '',        // regex for "failed" (informational)
    'balance_url'    => '',        // optional
    'balance_method' => 'GET',
    'balance_header' => '',
    'balance_key'    => '',        // JSON key holding the balance
], $url, 'lkey');

[
    'status'           => true,
    'url'              => 'https://…&toUser=##NUMBER##&messageContent=##SMS##',
    'send_key_mobile'  => 'toUser',
    'send_key_message' => 'messageContent',
]

use BluedotBd\LaravelBulksms\LaravelBulksms;

try {
    (new LaravelBulksms('lkey'))
        ->to('8801700000000')
        ->message('Your order #123 is on the way')   // or ->line('…')->line('…')
        ->send();
} catch (Exception $e) {
    // gateway unreachable, rejected by send_success, empty recipient/message…
}

use LaravelBulksms;

LaravelBulksms::to('8801700000000')->message('Hello from the facade')->send();

use BluedotBd\LaravelBulksms\Jobs\SendSMS;

dispatch(new SendSMS('lkey', $number, $message));
dispatch((new SendSMS('lkey', $number, $message))->onQueue('sms'));

use BluedotBd\LaravelBulksms\LaravelBulksms;
use BluedotBd\LaravelBulksms\SmsChannel;
use Illuminate\Notifications\Notification;

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

    public function toSms($notifiable)
    {
        return (new LaravelBulksms('lkey'))
            ->to($notifiable->mobile)
            ->line('Your order has shipped');
    }
}

$balance = (new LaravelBulksms('lkey'))->balance(); // float, 0.0 when unavailable
bash
php artisan vendor:publish --tag=laravel-bulksms-config