This is a simple PHP wrapper for SuperText Nigeria's SMS API gateway.
Using Composer:
composer require kheme/php-supertext-nigeria
Import the class before making your calls.
require_once 'vendor/autoload.php';
use Kheme\SuperTextNg\SMS;
$sms = new SMS('SUPERTEXTNG_USERNAME', 'SUPERTEXTNG_PASSWORD');
$sms->from('Kheme');
$sms->to('2348153332428')
$sms->message('Using the facade to send a message.')
$sms->send(); // returns true
If sending wasn't successful, an exception will be thrown.
You can send an SMS to multiple recipients by including multiple to()
in your call:
$sms = new SMS('SUPERTEXTNG_USERNAME', 'SUPERTEXTNG_PASSWORD');
$sms->from('Kheme');
$sms->to('2348153332428');
$sms->to('2348056511193');
$sms->message('Using the facade to send a message.');
$sms->send(); // returns true
Or, by supplying an array of phone numbers to a single to()
:
$sms = new SMS('SUPERTEXTNG_USERNAME', 'SUPERTEXTNG_PASSWORD');
$sms->from('Kheme');
$sms->to([
'2348153332428',
'2348056512393',
]);
$sms->message('Using the facade to send a message.');
$sms->send(); // returns true
To send SMS to numbers that have Do Not Disturb (DND) enabled, include ignoreDND()
to your call:
$sms = new SMS('SUPERTEXTNG_USERNAME', 'SUPERTEXTNG_PASSWORD');
$sms->from('Kheme');
$sms->to('2348153332428');
$sms->message('Using the facade to send a message.');
$sms->ignoreDND();
$sms->send(); // returns true
If you would like to return your account balance after sending, include returnBalance()
to your call:
$sms = new SMS('SUPERTEXTNG_USERNAME', 'SUPERTEXTNG_PASSWORD');
$sms->from('Kheme');
$sms->to('2348153332428');
$sms->message('Using the facade to send a message.');
$sms->returnBalance();
$sms->send(); // returns true
If you would like to return the total amount of units used after sending, include returnUnitsUsed()
to your call:
$sms = new SMS('SUPERTEXTNG_USERNAME', 'SUPERTEXTNG_PASSWORD');
$sms->from('Kheme');
$sms->to('2348153332428');
$sms->message('Using the facade to send a message.');
$sms->returnUnitsUsed();
$sms->send(); // returns true
The above method options, exluding the balance()
below, can be combined like in the following example:
$sms = new SMS('SUPERTEXTNG_USERNAME', 'SUPERTEXTNG_PASSWORD');
$sms->from('Kheme');;
$sms->to('2348153332428');
$sms->message('Using the facade to send a message.');
$sms->returnBalance();
$sms->returnUnitsUsed();
$sms->ignoreDND();
$sms->send(); // returns true
To check your SuperText Nigeria credit balance, simply call balance()
:
$sms = new SMS('SUPERTEXTNG_USERNAME', 'SUPERTEXTNG_PASSWORD');
return $sms->balance();
In the case of an error, a call will return an error as follows:
The numbers on the left are the corresponding error code from SuperText Nigeria, but will not be included in the error response
- 100: One or more required url parameter is missing or misspelt
- 101: Username is blank
- 102: Password is blank
- 103: Destination is blank
- 104: Message is blank
- 105: Sender is blank
- 200: Wrong username or password
- 201: Account has not been activated
- 202: Inactive account
- 300: Insufficient credit
- 400: Failed delivery (no credit deducted)