Code Monkey home page Code Monkey logo

sms-service-with-bd-providers's Introduction

SMS Gateway Library for Various Bangladesh SMS Providers

Latest Version on Packagist Build Status Quality Score StyleCI Total Downloads License PHP Version Require

Simple php library to interact with various SMS gateways to send SMS to the Bangladeshi mobile users with storing SMS request logs.

Installation

Please install this library with composer. Run the following composer command to add this library.

composer require sarahman/sms-service-with-bd-providers

Next, you need to install the service provider:

// app/config/app.php
    .....
    .....
    'providers' => [
        ...
        Sarahman\SmsService\SmsGatewayServiceProvider::class,
    ],
    .....
    .....

You can publish the config file with:

For Laravel version 4.*

php artisan config:publish sarahman/sms-service-with-bd-providers

For Laravel version greater than 4

php artisan vendor:publish --provider="Sarahman\SmsService\ServiceProviderForLaravelRecent"

This is the contents of the published config file:

<?php

use Sarahman\SmsService\Client;

return [
    'default' => [
        'provider' => Client::PROVIDER_SSL,
    ],

    'providers' => [
        Client::PROVIDER_BANGLALINK => [
            'url' => 'https://vas.banglalinkgsm.com/sendSMS/sendSMS',
            'userID' => '',
            'passwd' => '',
            'sender' => '',
        ],
        Client::PROVIDER_BD_WEB_HOST_24 => [
            'url' => 'http://sms.bdwebhost24.com/smsapi',
            'senderid' => '',
            'api_key' => '',
            'type' => 'text',
        ],
        Client::PROVIDER_BOOM_CAST => [
            'url' => 'http://api.boom-cast.com/boomcast/WebFramework/boomCastWebService/externalApiSendTextMessage.php',
            'userName' => '',
            'password' => '',
            'MsgType' => 'TEXT',
            'masking' => 'S.H.P.L',
        ],
        Client::PROVIDER_BULK_SMS_BD => [
            'url'      => 'http://bulksmsbd.net/api/smsapi',
            'api_key'  => '',
            'senderid' => '',
            'type'     => 'text',
        ],
        Client::PROVIDER_ELITBUZZ => [
            'url' => 'https://msg.elitbuzz-bd.com/smsapi',
            'api_key' => '',
            'senderid' => '',
            'type' => 'text',
        ],
        Client::PROVIDER_GRAMEENPHONE => [
            'url' => 'https://cmp.grameenphone.com/gpcmpapi/messageplatform/controller.home',
            'username' => '',
            'password' => '',
            'countrycode' => '880',
            'cli' => '',
            'apicode' => 1,
            'messagetype' => 1, // 1: Text; 2: Flash; 3: Unicode (Bangla)
            'messageid' => 0,
        ],
        Client::PROVIDER_NOVOCOM => [
            'url' => 'https://sms.novocom-bd.com/api/v2/SendSMS',
            'ApiKey' => '',
            'ClientId' => '',
            'SenderId' => '',
        ],
        Client::PROVIDER_PAYSTATION => [
            'url' => 'https://sms.shl.com.bd/sendsms',
            'user_id' => '',
            'password' => '',
            'type' => 'text',
        ],
        Client::PROVIDER_ROBI => [
            'url' => 'https://bmpws.robi.com.bd/ApacheGearWS/SendTextMessage',
            'Username' => '',
            'Password' => '',
            'From' => '',
        ],
        Client::PROVIDER_SSL => [
            'url' => 'http://sms.sslwireless.com/pushapi',
            'user' => '',
            'pass' => '',
            'sid' => '',
        ],
        Client::PROVIDER_VALUE_FIRST => [
            'url' => 'http://www.myvaluefirst.com/smpp/sendsms',
            'username' => '',
            'password' => '',
            'from' => '',
            'coding' => 3, // Unicode allows or not
        ],
    ],
    'enable_api_call_logging' => false,
];

Now, you need to set the default credentials of various SMS providers which are needed to be used.

N.B.: This library directly depends on the package: sarahman/laravel-http-request-api-log. Please follow this link to know the usages of this package.

Usages

<?php

use Sarahman\SmsService\Client;

require "vendor/autoload.php";

// Instantiate with default config
$smsSender = new Client(Client::getProvider(Client::PROVIDER_SSL));

// Or instantiate with custom config
$smsSender = new Client(Client::getProvider(Client::PROVIDER_SSL, [
    'user' => 'SSL_WIRELESS_USERNAME',
    'pass' => 'SSL_WIRELESS_PASSWORD',
    'sid' => 'SSL_WIRELESS_SID',
], 'SSL_WIRELESS_URL'));

try {
    $response = $smsSender->send($mobile, $message);

    if ($response['summary']['sent'] == $response['summary']['total']) {
        // Do for the successful response.
    } else {
        // Do for the failed response.
    }
} catch (Exception $e) {
    echo $e->getMessage();
}

Supported Providers

For Other Gateway Providers

If you have your own SMS gateway and you provide API. Please build your own provider and send us pull request. We will add those here too.

To build your own provider, please follow src/Interfaces/ProviderInterface.php.

If you have any questions, please feel free to create an issue or write us at [email protected]

Contributions

Feel free to contribute in this library. Add your own provider and send us pull requests.

Security Issues

If you discover any security related issues, please feel free to create an issue in the issue tracker or write us at [email protected].

License

The MIT License (MIT). Please see License File for more information.

sms-service-with-bd-providers's People

Contributors

shohoz-abid avatar sarahman avatar

Watchers

 avatar

Forkers

agrabbee

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.