Skip to content

omakei/laravel-nextsms

Repository files navigation

NextSMS Logo

Laravel NextSMS

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Laravel package to send SMS using NextSMS API.

Installation

You can install the package via composer:

composer require omakei/laravel-nextsms

You can publish the config file with:

php artisan vendor:publish --tag="nextsms-config"

The following keys must be available in your .env file:

NEXTSMS_USERNAME=
NEXTSMS_PASSWORD=
NEXTSMS_SENDER_ID=

This is the contents of the published config file:

return [
    'username' => env('NEXTSMS_USERNAME', 'NEXTSMS'),
    'password' => env('NEXTSMS_PASSWORD', 'NEXTSMS'),
    'api_key' => base64_encode(env('NEXTSMS_USERNAME', 'NEXTSMS').':'.env('NEXTSMS_PASSWORD', 'NEXTSMS')),
    'sender_id' => env('NEXTSMS_SENDER_ID', 'NEXTSMS'),
    'url' => [
        'sms' => [
            'single' => NextSMS::NEXTSMS_BASE_URL.'/api/sms/v1/text/single',
            'multiple' => NextSMS::NEXTSMS_BASE_URL.'/api/sms/v1/text/multi',
            'reports' => NextSMS::NEXTSMS_BASE_URL.'/api/sms/v1/reports',
            'logs' => NextSMS::NEXTSMS_BASE_URL.'/api/sms/v1/logs',
            'balance' => NextSMS::NEXTSMS_BASE_URL.'/api/sms/v1/balance',
        ],
        'sub_customer' => [
            'create' => NextSMS::NEXTSMS_BASE_URL.'/api/reseller/v1/sub_customer/create',
            'recharge' => NextSMS::NEXTSMS_BASE_URL.'/api/reseller/v1/sub_customer/recharge',
            'deduct' => NextSMS::NEXTSMS_BASE_URL.'/api/reseller/v1/sub_customer/deduct',
        ]
    ],
];

Usage

Send SMS

NB: Telephone Number Must Start with Valid Country Code. Example: 255625933171

Sending single sms to single destination:

use Omakei\NextSMS\NextSMS;

$response = NextSMS::sendSingleSMS(['to' => '255625933171', 'text' => 'Dj Omakei is texting.']);

Sending single sms to multiple destinations:

use Omakei\NextSMS\NextSMS;

$response = NextSMS::sendSingleSMSToMultipleDestination([
            'to' => ['255625933171','255656699895'], 
            'text' => 'Dj Omakei is texting.']);

Sending multiple sms to multiple destinations (Example 1):

use Omakei\NextSMS\NextSMS;

$response = NextSMS::sendMultipleSMSToMultipleDestinations(['messages' => [
                ['to' => '255625933171', 'text' => 'Dj Omakei is texting.'],
                ['to' => '255656699895', 'text' => 'Dj Omakei is texting.']
            ]]);

Sending multiple sms to multiple destinations (Example 2):

use Omakei\NextSMS\NextSMS;

$response = NextSMS::sendMultipleSMSToMultipleDestinations(['messages' => [
                ['to' => ['255625933171','255656699895'], 'text' => 'Dj Omakei is texting.'],
                ['to' => '255625933171', 'text' => 'Dj Omakei is texting.']
            ]]);

Schedule sms:

use Omakei\NextSMS\NextSMS;

$response = NextSMS::scheduleSMS([
            'to' => '255625933171', 
            'text' => 'Dj Omakei is texting.', 
            'date' => '2022-01-25' , 
            'time' => '12:00']);

SMS Delivery Reports

Get all delivery reports:

use Omakei\NextSMS\NextSMS;

$response = NextSMS::getAllDeliveryReports();

Get delivery reports with messageId:

use Omakei\NextSMS\NextSMS;

$response = NextSMS::getDeliveryReportWithMessageId(243452542526627);

Get delivery reports with messageId:

use Omakei\NextSMS\NextSMS;

$response = NextSMS::getDeliveryReportWithSpecificDateRange('2022-01-25', '2022-01-29');

Sent Sms Logs

Get all sent SMS logs:

use Omakei\NextSMS\NextSMS;

$response = NextSMS::getAllSentSMSLogs(10, 5);

Get all sent SMS logs with the optional parameter:

use Omakei\NextSMS\NextSMS;

$response = NextSMS::getAllSentSMSLogsWithOptionalParameter('255625933171','2022-01-25', '2022-01-29',10, 5);

Sub Customer

Register Sub Customer:

use Omakei\NextSMS\NextSMS;

$response = NextSMS::subCustomerCreate(
            'Michael', 
            'Omakei',
            'omakei',
            '[email protected]',
            '06259313171', 
            'Sub Customer (Reseller)', 
            100);

Recharge customer:

use Omakei\NextSMS\NextSMS;

$response = NextSMS::subCustomerRecharge('[email protected]', 100);

Deduct a customer:

use Omakei\NextSMS\NextSMS;

$response = NextSMS::subCustomerDeduct('[email protected]', 100);

Get sms balance:

use Omakei\NextSMS\NextSMS;

$response = NextSMS::getSMSBalance();

NextSMS API Documentation

Please see NextSMS Developer API for more details.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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

About

A Laravel package to send SMS using NextSMS API

Resources

License

Security policy

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages