hosannahighertech / yii2-sms
Yii2 component for sending SMS messages
Installs: 14
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Type:yii2-component
Requires
- php: >=7.4.0
- yiisoft/yii2: ~2.0.45
This package is auto-updated.
Last update: 2024-11-27 19:54:09 UTC
README
Send SMS from different gateways. See readme for currently supported gateways
How to use Library
To use the library, simply create Instance of the Sender that you want and send the message. Below is an example to get you started
$sms = new \hosannahighertech\sms\senders\BeemSender([ 'key' => 'YOUR_KEY_FROM_BEEM 'secret' => 'YOUR_SECRET_HERE', ]); $sms->send('SENDER_NAME_OR_NUMBER', ['255....', '255....'], 'Hi, Test Message from Yii2 SMS');
Events
This library support two events: beforeSend
which gives you the SMS that will be sent as a payload and afterSend
which gives you result from the backend. Here is an example on adding event handlers to the above example
$sms = new \hosannahighertech\sms\senders\BeemSender([ 'key' => 'YOUR_KEY_FROM_BEEM 'secret' => 'YOUR_SECRET_HERE', ]); $sender->on(SmsSenderInterface::EVENT_BEFORE_SEND, function (SMSEvent $event) { $event->message; //this is SMS Object that was sent to the server. Handy to log things if you turned off loggin }); $sender->on(SmsSenderInterface::EVENT_AFTER_SEND, function (SMSEvent $event) { $event->message; //this is data that comes from backend. For Beem, it is request_id }); $sms->send('SENDER_NAME_OR_NUMBER', ['255....', '255....'], 'Hi, Test Message from Yii2 SMS');
Supported Gateways
- BEEM Africa (see https://beem.africa/sms-api/ )