ngarak-dev / nextsms
A Laravel package to send SMS using NextSMS API. Basically a folk from https://github.com/omakei with updated packages support for laravel 10 and 11
Requires
- php: ^8.1
- guzzlehttp/guzzle: ^7.8
- illuminate/contracts: ^11.3
- illuminate/support: ^11.3
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- laravel/pint: ^1.15
- nunomaduro/collision: ^8.1
- nunomaduro/larastan: ^2.9
- orchestra/testbench: ^9.0
- pestphp/pest: ^2.34
- pestphp/pest-plugin-laravel: ^2.3
- pestphp/pest-plugin-mock: ^2.0
- phpstan/extension-installer: ^1.3
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-phpunit: ^1.3
- phpunit/phpunit: ^10.5.10
- spatie/laravel-ray: ^1.36
README
A Laravel package to send SMS using NextSMS API. Basically a folk from https://github.com/omakei with updated packages support for laravel 10 and 11
Installation
You can install the package via composer:
composer require ngarak-dev/nextsms
The following keys must be available in your .env
file:
NEXTSMS_USERNAME= NEXTSMS_PASSWORD= NEXTSMS_SENDER_ID=
Usage
Send SMS
NB: Telephone Number Must Start with Valid Country Code. Example: 255768491010
Sending single sms to single destination:
use NgarakDev\NextSMS\NextSMS; $response = NextSMS::sendSingleSMS(['to' => '25500000000', 'text' => 'Hellooooo Next.']);
Sending single sms to multiple destinations:
use NgarakDev\NextSMS\NextSMS; $response = NextSMS::sendSingleSMSToMultipleDestination([ 'to' => ['255000000000','255111111111'], 'text' => 'Helooooo.']);
Sending multiple sms to multiple destinations (Example 1):
use NgarakDev\NextSMS\NextSMS; $response = NextSMS::sendMultipleSMSToMultipleDestinations(['messages' => [ ['to' => '255000000000', 'text' => 'Helooo Next.'], ['to' => '255111111111', 'text' => 'Helooo Next.'] ]]);
Sending multiple sms to multiple destinations (Example 2):
use NgarakDev\NextSMS\NextSMS; $response = NextSMS::sendMultipleSMSToMultipleDestinations(['messages' => [ ['to' => ['25500000000','25500000000'], 'text' => 'Heloooooooo.'], ['to' => '25500000000', 'text' => 'Heloooooooo.'] ]]);
Schedule sms:
use NgarakDev\NextSMS\NextSMS; $response = NextSMS::scheduleSMS([ 'to' => '25500000000', 'text' => 'Heloooooooo.', 'date' => '2022-01-25' , 'time' => '12:00']);
SMS Delivery Reports
Get all delivery reports:
use NgarakDev\NextSMS\NextSMS; $response = NextSMS::getAllDeliveryReports();
Get delivery reports with messageId:
use NgarakDev\NextSMS\NextSMS; $response = NextSMS::getDeliveryReportWithMessageId(243452542526627);
Get delivery reports with messageId:
use NgarakDev\NextSMS\NextSMS; $response = NextSMS::getDeliveryReportWithSpecificDateRange('2022-01-25', '2022-01-29');
Sent Sms Logs
Get all sent SMS logs:
use NgarakDev\NextSMS\NextSMS; $response = NextSMS::getAllSentSMSLogs(10, 5);
Get all sent SMS logs with the optional parameter:
use NgarakDev\NextSMS\NextSMS; $response = NextSMS::getAllSentSMSLogsWithOptionalParameter('255000000000','2022-01-25', '2022-01-29',10, 5);
Sub Customer
Register Sub Customer:
use NgarakDev\NextSMS\NextSMS; $response = NextSMS::subCustomerCreate( 'Michael', 'Juma', 'test@gmail.com', '062500000000', 'Sub Customer (Reseller)', 100);
Recharge customer:
use NgarakDev\NextSMS\NextSMS; $response = NextSMS::subCustomerRecharge('otest@gmail.com', 100);
Deduct a customer:
use NgarakDev\NextSMS\NextSMS; $response = NextSMS::subCustomerDeduct('test@gmail.com', 100);
Get sms balance:
use NgarakDev\NextSMS\NextSMS; $response = NextSMS::getSMSBalance();
NextSMS API Documentation
Please see NextSMS Developer API for more details.
Testing
composer test