bluedot-bd/laravel-bulksms

'laravel-bulksms' is a Laravel package for integrating with an HTTP-based SMS gateway. The package is compatible with SMS providers in Bangladesh and other countries, and allows for the sending of notifications via Laravel notifications. It also includes a feature for checking the balance of an SMS

1.0.4 2024-04-17 18:25 UTC

This package is auto-updated.

Last update: 2024-09-17 19:19:23 UTC


README

Latest Version on Packagist Total Downloads GitHub Actions

"laravel-bulksms" is a Laravel package for integrating with any HTTP-based SMS gateway. The package is compatible with SMS providers in Bangladesh and other countries, and allows for the sending of notifications via Laravel notifications. It also includes a feature for checking the balance of an SMS account with a supported provider. This package can be useful for integrating SMS functionality into a Laravel-based application, sending sms messages to people, and keeping track of SMS usage and account balances.

Installation

You can install the package via composer:

composer require bluedot-bd/laravel-bulksms

Usage

Check and Save Config

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)
}

You can use it in Notification (for sending sms):

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();
}

or you can use it directly:

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

or Send SMS useing Laravel Queued Jobs

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));

Get Balance if Supported

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

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email saiful@bluedot.ltd instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.