A PHP class, which implements the Nexah API to send SMS.
It focuses on sending messages via Nexah API, and returns a boolean according to the success or the failure of the send method inside the class.
To get a Nexah account and start using their API, visit nexah/contac-us. Once there, fulfill the contact form and submit. Once done, you will get an email and an amployee of Nexah will give you a call for your account configuration.
- You need to have an account as describe above nexah/contac-us.
- Your username and password
- PHP 7.4 or higher
Installation is recommended to be done via [composer][] by running:
composer require karbura/nexah-sms
Alternatively you can add the following to the require
section in your composer.json
manually:
"karbura/nexah-sms"
Run composer update
afterwards.
// Instantiate the Nexahsms class into the file where you want to send and SMS
$sms = new NexahSMS();
// In the NexahSMS class, there is a method send_sms()
// this method takes as parameters:
// $user = your login received by Nexah team
// $password = your login password received by Nexah team
// $senderid = your name
// $sms = the message to be sent
// $mobiles = a number in string format or a coma seperated string of numbers to receive the message
$sms->send_sms($user, $password, $senderid, $sms, $modiles);
// An example of this is the following
$sms->send_sms("myloginemail@email.com", "myloginpassword", "My Name", "My message here", "xxxxxxxxx, xxxxxxxxx, xxxxxxxxx");
// keep in mind that this method returns a boolean, so you must assign the method to a variable and use it in an if condition to check wether the SMS is sent or not.
// send a message to a single receiver
$response = MessageBird::send(["+237653214587"], "My First SMS");
//Or
// set a list of receivers / recipients
$receivers = [
"receiver1",
"receiver2",
"receiver3",
...
]
// and then make a single call to send
$response = MessageBird::send(["+237653214587"], "Send Many SMS");
Thank you for using this extension and if there is any problem, feel free to report it.