Skip to content

Send bulk messages, otp message, notification with Laravel using sms.net.bd SMS Gateway in Bangladesh

License

Notifications You must be signed in to change notification settings

smsnetbd/sms-net-bd-laravel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SMS.NET.BD SMS Package for Laravel

Packagist version mit Packagist Downloads

SMS Package for Laravel - Simplify SMS integration with the SMS Gateway from sms.net.bd. Send messages, check balance, get delivery reports, and manage SMS effortlessly in your Laravel applications.

The SMS Laravel package provides convenient access to the sms.net.bd REST API from php applications.

Sign up for a free sms.net.bd account today and get your API Key from our advanced SMS platform. Plus, enjoy free credits to try out your API in full!

Example

Check out the other code examples

Features

  • Send SMS messages through the sms.net.bd sms gateway.
  • Schedule SMS messages for future delivery.
  • Send SMS to multiple recipients with sender id
  • Retrieve SMS delivery reports.
  • Check account balance and balance validity.

Requirements

  • Laravel Framework 7.x
  • PHP 7.2 or higher

Installation

Install the package via Composer:

composer require sms_net_bd/sms

Set your SMS API key in the .env file:

SMS_NET_BD_API_KEY=your-api-key

Note: Ensure to replace placeholder your-api-key with your actual API key

Usage

use sms_net_bd\SMS; // Import the SMS class

// Create an instance of the class
$sms = new SMS();

try {
    // Send Single SMS
    $response = $sms->sendSMS(
        "Hello, this is a test SMS!",
        "01701010101"
    );

    // Send Multiple Recipients SMS
    $response = $sms->sendSMS(
        "Hello, this is a test SMS!",
        "01701010101,+8801856666666,8801349494949,01500000000"
    );

    // Send SMS With Sender ID or Masking Name
    $response = $sms->sendSMS(
        "Hello, this is a test SMS!",
        "01701010101",
        "sms.net.bd"
    );

    // Schedule SMS for future delivery
    $response = $sms->sendScheduledSMS(
        "Scheduled SMS",
        "8801701010101",
        "2023-12-01 14:30:00" // Date format: YYYY-MM-DD HH:MM:SS
    );

    // Schedule SMS for future delivery with Sender ID
    $response = $sms->sendScheduledSMS(
        "Scheduled SMS with date",
        "8801701010101",
        "2023-12-01 14:30:00",
        "sms.net.bd"
    );

    // Get SMS delivery report
    $report = $sms->getReport($requestId);

    // Check account balance
    $balanceInfo = $sms->getBalance();

} catch (Exception $e) {
    // handle $e->getMessage();
}

Note: Ensure to replace placeholder values with your phone numbers and messages.

Error Handling

The package provides better error handling. If the API response has an error (error != 0), an exception is thrown with the error message.

try {
    $response = $sms->sendSMS('Invalid Recipient', '+invalid-number');
} catch (\Exception $e) {
    // Handle the exception, log the error, or display a user-friendly message.
    echo 'Error: ' . $e->getMessage();
}

License

This package is open-source software licensed under the MIT license

Contribution

Contributions are welcome! Feel free to submit issues or open a pull request.

Support

If you have any questions or feedback, please open an issue or open a pull request.