xenon / laravelbdsms
This is package for sending sms to Bangladeshi mobile numbers using laravel application
Fund package maintenance!
Patreon
www.buymeacoffee.com/arif98741
Installs: 4 271
Dependents: 0
Suggesters: 0
Security: 0
Stars: 136
Watchers: 5
Forks: 50
Open Issues: 0
Requires
- php: ^8.1
- ext-curl: *
- ext-json: *
- guzzlehttp/guzzle: ^6.3|^7.3
- dev-master
- V1.0.64.1
- V1.0.64.0
- V1.0.63.0
- V1.0.62.0
- V1.0.61.0
- V1.0.60.3
- V1.0.60.2
- V1.0.60.1
- V1.0.60.0
- V1.0.59.3
- V1.0.59.2
- V1.0.59.1
- V1.0.59.0
- v1.0.58.1
- V1.0.58.0
- V1.0.57.2
- v1.0.57.1
- v1.0.57.0
- v1.0.56.0
- v1.0.56.0-alpha
- v1.0.55.0-alpha
- v1.0.54.0
- v1.0.53.0
- v1.0.52.0
- v1.0.52.0-beta
- v1.0.51.0
- v1.0.51.0-beta
- v1.0.50.5
- v1.0.50.4
- v1.0.50.3
- v1.0.50.2
- v1.0.50.1
- v1.0.50.0
- v1.0.49.3
- v1.0.49.2
- v1.0.49.1
- v1.0.49.0
- v1.0.48.1
- v1.0.47.2
- v1.0.47.0
- v1.0.46.2
- v1.0.46.1
- v1.0.46.0
- v1.0.45.5
- v1.0.45.3
- v1.0.45.2
- v1.0.45.1
- v1.0.45.0
- v1.0.44.3
- v1.0.44.2
- v1.0.44.1
- v1.0.44.0
- v1.0.43.0
- v1.0.42.1
- v1.0.42.0
- v1.0.41.5
- v1.0.41.2
- v1.0.41.1
- v1.0.41.0
- v1.0.41-beta
- v1.0.40.0
- v1.0.39.0
- v1.0.38.5
- v1.0.38.4
- v1.0.38.3
- v1.0.38.2
- v1.0.38.1
- v1.0.38.0
- v1.0.37.3
- v1.0.37.2
- v1.0.37.1
- v1.0.37.0
- v1.0.36.7
- v1.0.36.6
- v1.0.36.5
- v1.0.36.4
- v1.0.36.3
- v1.0.36.2
- v1.0.36.1
- v1.0.36
- v1.0.36-rc1
- v1.0.35-rc-2
- v1.0.35-rc1
- v1.0.34
- v1.0.33
- v1.0.32
- v1.0.31
- v1.0.31-beta
- v1.0.31-alpha
- v1.0.30
- v1.0.29
- v1.0.28
- v1.0.27
- v1.0.26
- v1.0.25
- v1.0.24
- v1.0.23
- v1.0.19
- v1.0.18
- v1.0.17
- v1.0.16
- v1.0.15
- v1.0.14
- v1.0.13
- v1.0.12
- v1.0.9
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- dev-temp_elitebuzz_urlenconde
- dev-dev
- dev-testing
- dev-quicksms-gateway
- dev-muthofun-sms-gateway
- dev-alpha_sms_fixing
- dev-feat-grameenphone-sms
- dev-trubosms_gateway
- dev-doc
- dev-SmsNOC_sms_gateway
- dev-SmsinBD_gateway
- dev-smsnet24-gateway
- dev-redmoit_sms_gateway
- dev-smartlabsms-gateway
- dev-patch-1
- dev-sms_queue
- dev-feature_logger
- dev-otp_verify
This package is auto-updated.
Last update: 2024-10-28 16:57:41 UTC
README
Xenon\LaravelBDSms is a sms gateway package for sending text message to Bangladeshi mobile numbers using several gateways for Laravel Framework. You can watch installation process from youtube.
Installation
Step 1:
composer require xenon/laravelbdsms
Step 2:
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
Step 3:
Step 4:
php artisan config:cache && php artisan migrate
Usage
Simply use the facade
Note: 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)
use Xenon\LaravelBDSms\Facades\SMS; SMS::shoot('017XXYYZZAA', 'helloooooooo boss!'); SMS::shoot(['017XXYYZZAA','018XXYYZZAA'], 'helloooooooo boss!');
Or, with facade alias
use LaravelBDSms, SMS; LaravelBDSms::shoot('017XXYYZZAA', 'helloooooooo boss!'); SMS::shoot('017XXYYZZAA', 'helloooooooo boss!');
Or, if you need to change the default provider on the fly
use Xenon\LaravelBDSms\Facades\SMS; use Xenon\LaravelBDSms\Provider\Ssl; $response = SMS::via(Ssl::class)->shoot('017XXYYZZAA', 'helloooooooo boss!');
Or, you can send message with queue. This queue will be added in your jobs table. Message will be sent as soon as job is run.
Make sure you have jobs table and other jobs related functionalities enabled
use Xenon\LaravelBDSms\Facades\SMS; use Xenon\LaravelBDSms\Provider\Ssl; SMS::shootWithQueue("01XXXXXXXXX",'test sms'); SMS::via(Ssl::class)->shootWithQueue("01XXXXXXXXX",'test sms');
Log Generate
You can generate log for every sms api request and save in database or file. For doing this. Follow below points
- Laravelbdsms stores log in two drivers(
database, file
).database
is default. You can change it from config/sms.php - Find and make true
'sms_log' => true,
- Be confirm you have completed step-2 and step-3
- For
database
driver- Change log driver to
log_driver =>'database'
fromconfig/sms.php
- Run command
php artisan migrate
. This will createlbs_log
table in your database
- Change log driver to
- For
file
driver- Change log driver to
log_driver =>'file'
fromconfig/sms.php
- Change log driver to
Otherwise, if you want more control, you can use the underlying sender object. This will not touch any laravel facade or service provider.
Sample Code
SSLCommerz
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(); ----------Demo Response Using SSL------------- array:6 [▼ "status" => "response" "response" => "{"status":"FAILED","status_code":4003,"error_message":"IP Blacklisted"}" "provider" => "Xenon\LaravelBDSms\Provider\Ssl" "send_time" => "2021-07-06 08:03:23" "mobile" => "017XXYYZZAA" "message" => "helloooooooo boss!" ] --------------------------------------------------
Sms Send Using Custom Gateway
We have tried to added most of the gateways of Bangladesh in this package as much as possible. But still if you don't find your expected gateway in this list, then use Custom Gateway using following code snippet.
use Xenon\LaravelBDSms\Provider\CustomGateway; use Xenon\LaravelBDSms\Sender; $sender = Sender::getInstance(); $sender->setProvider(CustomGateway::class); $sender->setUrl('https://your_cusom_gateway_provider_url_here') ->setMethod('post') ->setHeaders([ 'Content-Type: application/json', 'Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', ], false); $sender->setMobile('017XXYYZZAA'); $sender->setMessage('text message goes here'); $sender->setQueue(false); //use required parameters based on your sms gateway. This will be changed according to need $sender->setConfig( [ 'MsgType' => 'TEXT', 'masking' => 'sample', 'userName' => 'test_user', 'message' => 'test message', 'receiver' => '017xxxxxxxxxx', ] ); echo $status = $sender->send();
Currently Supported Sms Gateways
Stargazers
Forkers
Contributors
We are continuously working in this open source library for adding more Bangladeshi sms gateway. If you feel something is missing then make a issue regarding that. If you want to contribute in this library, then you are highly welcome to do that....
For clear documentation read this blog in Medium! and also you can download several sms providers documentations as pdf from this link!
Special thanks to
tusharkhan
tusher9352