ozerich/yii2-rocketsms
最新稳定版本:1.0.1
Composer 安装命令:
composer require ozerich/yii2-rocketsms
包简介
Yii2 component for SMS provider RocketSMS.by
README 文档
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.jsonfile. -
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'; }
统计信息
- 总下载量: 2.22k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-05-19