shipu / banglalink-sms-gateway
Banglalink sms gateway
Installs: 907
Dependents: 0
Suggesters: 0
Security: 0
Stars: 29
Watchers: 3
Forks: 20
Open Issues: 0
Requires
- nahid/apiz: ^1.1
This package is auto-updated.
Last update: 2024-12-19 11:05:35 UTC
README
A PHP client for Banglalink SMS Gateway API. This package is also support Laravel and Lumen.
Installation
Go to terminal and run this command
composer require shipu/banglalink-sms-gateway
Wait for few minutes. Composer will automatically install the package for your project.
For Laravel
Below Laravel 5.5 open config/app
and add this line in providers
section
Shipu\BanglalinkSmsGateway\Providers\BanglalinkSmsGatewayServiceProvider::class,
For Facade support you have to add this line in the aliases
section.
'Banglalink' => Shipu\BanglalinkSmsGateway\Facades\Banglalink::class,
Then run this command
php artisan vendor:publish --provider="Shipu\BanglalinkSmsGateway\Providers\BanglalinkSmsGatewayServiceProvider"
For PHP Configuration
This package is required two configurations.
- user_id = your user_id which is provided by Banglalink.
- password = your password which is also provided by Banglalink.
banglalink-sms-gateway is take an array as config file. Lets services
use Shipu\BanglalinkSmsGateway\Banglalink; $config = [ 'user_id' => 'Your User Id', 'password' => 'Your Password' ]; $sms = new Banglalink($config);
For Laravel Configuration
This package is also support Laravel. For laravel you have to configure it as laravel style.
Go to config/banglalink-sms-gateway.php
and configure it with your credentials.
return [ 'user_id' => 'Your User id', 'password' => 'Your Password' ];
Usages
Its very easy to use. This packages has a lot of functionalities and features.
Send SMS to a single user
In PHP:
use \Shipu\BanglalinkSmsGateway\Services\Banglalink; ... $sms = new Banglalink($config); $response = $sms->message('your text here !!!', '01606022000')->send(); // Guzzle Response with request data // For another example please see below laravel section. return $response->autoParse(); // Getting only response contents.
In Laravel:
use \Shipu\BanglalinkSmsGateway\Facades\Banglalink; ... $sms = Banglalink::message('your text here !!!', '01606022000')->send(); // Guzzle Response with request data // or $sms = Banglalink::message('your text here !!!')->to('01606022000')->send(); // or $sms = Banglalink::send( [ 'message' => "your text here", 'to' => '01616022000' ] ); return $sms->autoParse(); // Getting only response contents.
Send same message to all users
$sms = Banglalink::message('your text here !!!') ->to('01616022669') ->to('01845736124') ->to('01745987364') ->send(); // or you can try below statements also $sms = Banglalink::message('your text here !!!', '01616022669') ->to('01845736124') ->to('01745987364') ->send(); // or $users = [ '01616022669', '01845736124', '01745987364' ]; $sms = Banglalink::message('your text here !!!',$users)->send();
Send SMS to more user
$sms = Banglalink::message('your text here one !!!')->to('01616022669') ->message('your text here two !!!')->to('01845736124') ->message('your text here three !!!')->to('01745987364') ->send(); // or $sms = Banglalink::message('your text here one !!!', '01616022669') ->message('your text here two !!!', '01845736124') ->message('your text here three !!!', '01745987364') ->send(); // or $sms = Banglalink::send([ [ 'message' => "your text here one !!!", 'to' => '01616022669' ], [ 'message' => "your text here two !!!", 'to' => '01707722669' ], [ 'message' => "your text here three !!!", 'to' => '01745987364' ] ]); // or $sms = Banglalink::message('your text here one !!!', '01616022669')->send([ [ 'message' => "your text here two !!!", 'to' => '01707722669' ], [ 'message' => "your text here three !!!", 'to' => '01745987364' ] ]);
Send SMS with SMS template
Suppose you have to send SMS to multiple users but you want to mention their name dynamically with message. So what can you do? Ha ha this package has already handled this situation. Lets see
$users = [ ['01670420420', ['Nahid', '1234']], ['01970420420', ['Rana', '3213']], ['01770420420', ['Shipu', '5000']], ['01570420420', ['Kaiser', '3214']], ['01870420420', ['Eather', '7642']] ] $sms = new \Shipu\BanglalinkSmsGateway\Services\Banglalink(config('banglalink-sms-gateway')); $msg = $sms->message("Hello %s , Your promo code is: %s", $users)->send(); // or $users = [ '01670420420' => ['Nahid', '1234'], '01970420420' => ['Rana', '3213'], '01770420420' => ['Shipu', '5000'], '01570420420' => ['Kaiser', '3214'], '01870420420' => ['Eather', '7642'] ] $sms = new \Shipu\BanglalinkSmsGateway\Services\Banglalink(config('banglalink-sms-gateway')); $msg = $sms->message("Hello %s , Your promo code is: %s", $users)->send();
Here this message will be sent to every users with his/her name and promo code like:
8801670420420
- Hello Nahid , Your promo code is: 12348801970420420
- Hello Rana , Your promo code is: 32138801770420420
- Hello Shipu , Your promo code is: 50008801570420420
- Hello Kaiser , Your promo code is: 12348801870420420
- Hello Eather , Your promo code is: 7642
Change Number Prefix
$sms = Banglalink::numberPrefix('91')->message('your text here !!!', '01606022000')->send();
Default number prefix is 88
;
Send sms with sender name
$sms = Banglalink::sender('XYZ Company')->message('your text here !!!', '01606022000')->send();
Default sender name is null
. for details please contact to banglalink customer support;
Debugging
$sms = Banglalink::debug(true)->message('your text here !!!', '01606022000')->send(); // // debug true or blank.
Default value is false
. When debug true
it's stop sending SMS and return sending query strings.
Response Data auto parse
$sms = Banglalink::autoParse(true)->message('your text here !!!', '01606022000')->send(); // autoParse true or blank.
Default value is false
.
Disable Template
$sms = Banglalink::template(false)->message('your text here !!!', '01606022000')->send();
Default value is true
.
Response Data
dd($sms);
Response :
Response {#463 ▼ #response: Response {#446 ▶} #request: Request {#428 ▼ -method: "GET" -requestTarget: null -uri: Uri {#429 ▶} -headers: [] -headerNames: [] -protocol: "1.1" -stream: null +"details": array:3 [▼ "url" => "https://vas.banglalinkgsm.com/sendSMS/sendSMS" "method" => "GET" "parameters" => array:1 [▼ "query" => array:5 [▶] ] ] } #contents: "Success Count : 2 and Fail Count : 0" }
Response auto parse:
dd($sms->autoParse());
Response
"Success Count : 2 and Fail Count : 0"
Response Details
$sms = Banglalink::details()->message('your text here !!!', '01606022000')->send();
Response:
[
'success' => 1,
'failed' => 0
]