baha2odeh / yii2-nexmo
Yii2 nexmo 是 Nexmo PHP 库的包装器。允许 Yii2 应用使用 Nexmo 服务。
2.0
2019-10-10 12:18 UTC
Requires
- php: >=5.4
- php-http/client-implementation: ^1.0
- php-http/guzzle6-adapter: ^1.0
- yiisoft/yii2: 2.0.*
- zendframework/zend-diactoros: ^1.3
Requires (Dev)
- php-http/mock-client: ^0.3.0
- phpunit/phpunit: ^5.3
README
Nexmo yii2 包装器。在 Yii2 应用中启用 Nexmo 服务。
安装
安装此扩展的首选方式是通过 composer。
运行以下命令之一:
php composer.phar require dpodium/yii2-nexmo "*"
或者在您的 composer.json
文件的 require 部分添加:
"dpodium/yii2-nexmo": "*"
to the require section of your composer.json
file.
组件设置
安装扩展后,只需按照以下方式修改您的应用程序配置:
return [ 'components' => [ ... 'nexmo' => [ 'class' => dpodium\yii2\Nexmo\NexmoManager::class, 'config' => [ 'api.key' => API_KEY, //from nexmo 'api.secret' => API_SECRET, //from nexmo ], //leave blank if not applicable 'proxy' => [ 'host' => HOST, 'port' => PORT, ], ], ... ], ... ];
使用方法
Sending message
Yii::$app->nexmo->sendSms(TO, FROM, 'Test Nexmo Message');
Receiving A Message
Yii::$app->nexmo->receiveMessage();
Fetching A Message
Yii::$app->nexmo->fetchMessage(MESSAGE_ID);
Starting a Verification
Yii::$app->nexmo->initVerification(NUMBER, BRAND);
Controlling a Verification
Trigger
Yii::$app->nexmo->triggerVerification(REQUEST_ID);
Cancel
Yii::$app->nexmo->cancelVerification(REQUEST_ID);
Checking A Verification
Yii::$app->nexmo->checkVerification(REQUEST_ID, CODE);
Searching For A Verification
Yii::$app->nexmo->searchVerification(REQUEST_ID);