PHP code example of shipu / banglalink-sms-gateway

1. Go to this page and download the library: Download shipu/banglalink-sms-gateway 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/ */

    

shipu / banglalink-sms-gateway example snippets


Shipu\BanglalinkSmsGateway\Providers\BanglalinkSmsGatewayServiceProvider::class,

'Banglalink'   =>  Shipu\BanglalinkSmsGateway\Facades\Banglalink::class,

use Shipu\BanglalinkSmsGateway\Banglalink;

$config = [
    'user_id' => 'Your User Id',
    'password' => 'Your Password'
];

$sms = new Banglalink($config);

return [
    'user_id' => 'Your User id',
    'password' => 'Your Password'
];

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.

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.

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

$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'
    ]
]);         

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

$sms = Banglalink::numberPrefix('91')->message('your text here !!!', '01606022000')->send();

$sms = Banglalink::sender('XYZ Company')->message('your text here !!!', '01606022000')->send();

$sms = Banglalink::debug(true)->message('your text here !!!', '01606022000')->send(); // // debug true or blank.

$sms = Banglalink::autoParse(true)->message('your text here !!!', '01606022000')->send(); // autoParse true or blank.

$sms = Banglalink::template(false)->message('your text here !!!', '01606022000')->send();

dd($sms);

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

dd($sms->autoParse());

$sms = Banglalink::details()->message('your text here !!!', '01606022000')->send();
shell
php artisan vendor:publish --provider="Shipu\BanglalinkSmsGateway\Providers\BanglalinkSmsGatewayServiceProvider"