ozerich / yii2-rocketsms
Yii2 component for SMS provider RocketSMS.by
Installs: 2 103
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- php: >=5.5
- myclabs/php-enum: ~1.0
- yiisoft/yii2: ~2.0.0
This package is not auto-updated.
Last update: 2024-11-24 06:09:55 UTC
README
Yii2 component for SMS provider RocketSMS.by
Installation
-
The preferred way to install this extension is through composer.
Either run
php composer.phar require ozerich/yii2-rocketsms "*"
or add
"ozerich/yii2-rocketsms": "*"
to the require section of your
composer.json
file. -
Add component configuration to your config.php
'components' => [ 'sms' => [ 'class' => 'blakit\rocketsms\RocketSms', 'login' => 'your_login', 'password' => 'your_password' ] ]
Usage
Send SMS:
try { $response = \Yii::$app->sms->send('+375296000000', 'Test Message'); echo 'SMS sent, message ID is ' . $response->getMessageId(); } catch (ErrorResponseException $exception) { echo 'Error sending SMS: ' . $exception->getError(); } catch (InvalidCredentialsException $exception) { echo 'RocketSMS credentials are invalid'; }
Check Balance:
try { $response = \Yii::$app->sms->balance(); echo 'Your balance: ' . $response->getBalance() . 'BYN, ' . $response->getCredits() . ' SMS'; } catch (InvalidCredentialsException $exception) { echo 'RocketSMS credentials are invalid'; }
Get message status:
try { $response = \Yii::$app->sms->status('MESSAGE_ID'); echo 'Message status: ' . $response->getStatus(); } catch (ErrorResponseException $exception) { echo 'Message not found'; } catch (InvalidCredentialsException $exception) { echo 'RocketSMS credentials are invalid'; }