Send Text Message to Bangladeshi Mobile Using Laravelbdsms from Laravel

Laravelbdsms is a popular sms sending package for sending message from laravel application using different gateways. The main goal of this package is to reduce hassle and provide easy way for developers so that they don't need to read documentation again and again for different sms gateway providers. Different sms gateway companies have different sms sending api, api credentials and their way of sending sms method might be different(get, post etc.);

Let's try to send sms using laravelbdsms package

Install laravelbdsms in Laravel Application

composer require xenon/laravelbdsms

Publish the Package Using Command

php artisan vendor:publish --provider=Xenon\LaravelBDSms\LaravelBDSmsServiceProvider --tag="migrations"
php artisan vendor:publish --provider=Xenon\LaravelBDSms\LaravelBDSmsServiceProvider --tag="config"
php artisan migrate
Select Vendor Laravelbdsms and It will Publish config/sms.php and migration

 

Usage

You can send sms using Sms facade or using full class object

For sending message using facade you must have to set .env credentials and set default provider; Find .env credentials for different providers from inside config/sms.php)

Sms Using Facade

use Xenon\LaravelBDSms\Facades\SMS;

SMS::shoot('017XXYYZZAA', 'helloooooooo boss!');
SMS::shoot(['017XXYYZZAA','018XXYYZZAA'], 'helloooooooo boss!'); 

Facade Sms Sending Along with Queue

This queue will be added in your jobs table. Message will be sent as soon as job is run

use Xenon\LaravelBDSms\Facades\SMS;
use Xenon\LaravelBDSms\Provider\Ssl;

SMS::shootWithQueue("01XXXXXXXXX",'test sms');
SMS::via(Ssl::class)->shootWithQueue("01XXXXXXXXX",'test sms');


Send Sms By Calling Class and Object

use Xenon\LaravelBDSms\Provider\Ssl;
use Xenon\LaravelBDSms\Sender;

$sender = Sender::getInstance();
$sender->setProvider(Ssl::class); //change this provider class according to need
$sender->setMobile('017XXYYZZAA');
//$sender->setMobile(['017XXYYZZAA','018XXYYZZAA']);
$sender->setMessage('helloooooooo boss!');
$sender->setQueue(true); //if you want to sent sms from queue
$sender->setConfig(
   [
       'api_token' => 'api token goes here',
       'sid' => 'text',
       'csms_id' => 'sender_id'
   ]
);
$status = $sender->send();

For more info visit official package github link

Tags: