sarahman / sms-service-with-bd-providers by sarahman

SMS Gateway service library in PHP. Multiple providers of Bangladesh in one library
1,532
0
1
Package Data
Maintainer Username: sarahman
Maintainer Contact: aabid048@gmail.com (Syed Abidur Rahman)
Package Create Date: 2023-09-02
Package Last Update: 2024-03-29
Language: PHP
License: MIT
Last Refreshed: 2024-04-21 03:00:19
Package Statistics
Total Downloads: 1,532
Monthly Downloads: 239
Daily Downloads: 0
Total Stars: 0
Total Watchers: 1
Total Forks: 1
Total Open Issues: 0

SMS Gateway Library for Various Bangladesh SMS Providers

Latest Version on Packagist Build Status Quality Score StyleCI Total Downloads

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:

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

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_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 aabid048@gmail.com

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 aabid048@gmail.com.

License

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