Skip to content

abusalam/laravel-smsgateway

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Send SMS from your Laravel app License

Latest Stable Version Total Downloads Build Status Code Intelligence Status Scrutinizer Code Quality

The abusalam/laravel-smsgateway package provides easy to use functions to send sms from your app. Works with CDAC SMS Gateway Services out of the box.

Here's a demo of how you can use it:

use AbuSalam\SmsGateway;

# Code...

$smsGateway = new SmsGateway;
$smsGateway->toRecipient('9876543210')
    ->withTemplateId('123456789012345678')
    ->withSms('Computer science is no more about computers than astronomy is about telescopes. - Edsger Dijkstra')
    ->sendSms();

# Code...

Documentation

You'll find the documentation here.

Installation

You can install the package via composer:

composer require "abusalam/laravel-smsgateway"

The package will automatically register itself.

You can optionally publish the config file with:

php artisan vendor:publish --provider="AbuSalam\SmsGatewayServiceProvider" --tag="config"

This is the contents of the published config file:

return [

    /*
    |--------------------------------------------------------------------------
    | Default SMS Gateway Name
    |--------------------------------------------------------------------------
    |
    | Here you may specify which of the SMS Gateways below you wish
    | to use as your default SMS Gateway for sending SMSs. Of course
    | you may use many connections at once using the SMS Gateway library.
    |
    */
    'default' => env('SMS_GATEWAY', 'local'),

    /*
    |--------------------------------------------------------------------------
    | SMS Gateways
    |--------------------------------------------------------------------------
    |
    | Here are each of the SMS Gateways setup for your application.
    | Of course, examples of configuring each SMS Gateway platform that is
    | supported by Laravel is shown below to make development simple.
    |
    |
    | All SMS Gateway work in Laravel is done through the PHP SMS facilities
    | so make sure you have the driver for your particular SMS Gateway of
    | choice installed on your machine before you begin development.
    |
    */

    /*=============================================================
    =            Default SMS Gateway API Configuration            =
    =============================================================*/
    'cdacSms' => [
        /* SMS Gateway API Endpoint Configurations */
        'apiEndpoint'       => env('SMS_URL', 'https://msdgweb.mgov.gov.in/esms/sendsmsrequestDLT'),
        'apiMobileNoParam'  => env('SMS_MOBILE_NO_PARAM', 'mobileno'),
        'apiSmsParam'       => env('SMS_SMS_PARAM', 'content'),
        /* SMS Gateway Constant Parameter Configurations */
        'apiParams'         => [
            'apiUserParam'        => env('SMS_USERNAME_PARAM', 'username'),
            'apiPassParam'        => env('SMS_PASSWORD_PARAM', 'password'),
            'apiSenderIdParam'    => env('SMS_SENDER_ID_PARAM', 'senderid'),
            'apiTemplateIdParam'  => env('SMS_TEMPLATE_ID_PARAM', 'templateid'),
            'apiSecureKeyParam'   => env('SMS_API_KEY_PARAM', 'key'),
            'apiServiceTypeParam' => env('SMS_SERVICE_TYPE_PARAM', 'smsservicetype'),
        ],
        'apiValues'     => [
            'apiUser'        => env('SMS_USERNAME', 'dummyuser'),
            'apiPass'        => sha1(trim(env('SMS_PASSWORD', 'dummypass'))),
            'apiSenderId'    => env('SMS_SENDER_ID', 'DUMMY'),
            'apiTemplateId'  => env('SMS_TEMPLATE_ID', '01235468238656'),
            'apiSecureKey'   => env('SMS_API_KEY', 'top-secret-dummy-key'),
            'apiServiceType' => env('SMS_SERVICE_TYPE_PARAM', 'singlemsg'),
        ]
    ],
    /*=====  End of Default SMS Gateway API Configuration  ======*/

    'local' => [
        /* SMS Gateway API Endpoint Configurations */
        'apiEndpoint'       => 'http://insp.local.host/api/sms',
        'apiMobileNoParam'  => 'recipient',
        'apiSmsParam'       => 'sms',
        /* SMS Gateway Parameter Configurations */
        'apiParams'         => [
            'apiUserParam'      => env('SMS_USERNAME_PARAM', 'username'),
            'apiPassParam'      => env('SMS_PASSWORD_PARAM', 'password'),
            'apiSenderIdParam'  => env('SMS_SENDER_ID_PARAM', 'senderid'),
            'apiSecureKeyParam' => env('SMS_API_KEY_PARAM', 'key'),
        ],
        'apiValues'     => [
            'apiUser'       => env('SMS_USERNAME', 'dummyuser'),
            'apiPass'       => sha1(trim(env('SMS_PASSWORD', 'dummypass'))),
            'apiSenderId'   => env('SMS_SENDER_ID', 'DUMMY'),
            'apiSecureKey'  => env('SMS_API_KEY', 'top-secret-dummy-key'),
        ]
    ],
];

License

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

About

Send SMS from Laravel 5.7

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages