omakei / laravel-nextsms
A Laravel package to send SMS using NextSMS API
Fund package maintenance!
omakei
Requires
- php: ^8.0
- guzzlehttp/guzzle: ^7.4
- illuminate/contracts: ^9.0
- spatie/laravel-package-tools: ^1.9.2
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^6.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- pestphp/pest-plugin-mock: ^1.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
- spatie/laravel-ray: ^1.26
This package is auto-updated.
Last update: 2024-11-11 13:37:39 UTC
README
Laravel NextSMS
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', 'omakei96@gmail.com', '06259313171', 'Sub Customer (Reseller)', 100);
Recharge customer:
use Omakei\NextSMS\NextSMS; $response = NextSMS::subCustomerRecharge('omakei96@gmail.com', 100);
Deduct a customer:
use Omakei\NextSMS\NextSMS; $response = NextSMS::subCustomerDeduct('omakei96@gmail.com', 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.