Giter Club home page Giter Club logo

sms-net-bd-laravel's Introduction

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.

sms-net-bd-laravel's People

Contributors

md-riaz avatar mdashraful305 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

mdashraful305

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.