autoxloo / yii2-twilio
Twilio短信PHP SDK的Yii2封装
1.0
2018-09-20 08:44 UTC
Requires
- php: >=5.5.0
- twilio/sdk: ~5.21.4
- yiisoft/yii2: ~2.0.0
Requires (Dev)
This package is auto-updated.
Last update: 2024-09-15 14:07:41 UTC
README
Yii2封装Twilio短信PHP SDK
注意:此包不支持
安装
安装此扩展的首选方式是通过 composer。
运行以下命令之一:
php composer.phar require --prefer-dist autoxloo/yii2-twilio "*"
composer require --prefer-dist autoxloo/yii2-twilio "*"
或
"autoxloo/yii2-twilio": "*"
将以下内容添加到您的 composer.json
文件的require部分。
配置
在您的应用程序配置中添加
// ... 'components' => [ // ... 'twilioSms' => [ 'class' => \autoxloo\yii2\twilio\sms\TwilioSms::class, 'sid' => 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', // Your Account Sid from twilio.com/user/account 'token' => 'your_auth_token', // Your Account Auth Token from twilio.com/user/account ], ],
用法
一旦安装了扩展,只需在代码中通过以下方式使用它
\Yii::$app->twilioSms->sendSms( '+15558675309', // the number you'd like to send the message to [ TwilioSms::OPTION_FROM => '+15017250604', // A Twilio phone number you purchased at twilio.com/console TwilioSms::OPTION_BODY => 'Hey Jenny! Good luck on the bar exam!', // the body of the text message you'd like to send ] );