PHP code example of munshiprodip / bulksmsbd-laravel

1. Go to this page and download the library: Download munshiprodip/bulksmsbd-laravel 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/ */

    

munshiprodip / bulksmsbd-laravel example snippets


return [
    'api_key' => env('BULKSMSBD_API_KEY', ''),
    'sender_id' => env('BULKSMSBD_SENDER_ID', ''),
    'base_url' => env('BULKSMSBD_BASE_URL', 'http://bulksmsbd.net'),
    'timeout' => (int) env('BULKSMSBD_TIMEOUT', 15),
    'throw_exceptions' => (bool) env('BULKSMSBD_THROW_EXCEPTIONS', true),
];

use BulkSmsBd\Laravel\Facades\BulkSmsBd;

// 1. Check Credit Balance
$balanceInfo = BulkSmsBd::getBalance();
/*
  Returns: 
  [
    "response_code" => 202,
    "balance" => 49.65,
    "status_message" => "SMS Submitted Successfully",
    "is_success" => true
  ]
*/

// 2. Send Single / Bulk SMS
$response = BulkSmsBd::send('88016xxxxxxxx', 'Your OTP is 1234');

if ($response['is_success']) {
    // SMS Sent successfully
} else {
    // Show user-friendly error
    echo $response['status_message']; // e.g., "Insufficient Balance"
}

// 3. Send Many-to-Many SMS (Distinct messages to different numbers)
$manyResponse = BulkSmsBd::sendMany([
    ['to' => '8801711111111', 'message' => 'Hello User 1, your invoice is ready.'],
    ['to' => '8801822222222', 'message' => 'Hello User 2, your invoice is ready.'],
]);

use BulkSmsBd\Laravel\Exceptions\BulkSmsBdException;

$message = BulkSmsBdException::getMessageForCode(1007);
// Returns: "Insufficient Balance"
bash
php artisan vendor:publish --tag="bulksmsbd-config"