liangzoe / yii2-mobilesmser
yii2 的 SMS 扩展
v1.1
2015-09-10 07:01 UTC
Requires
- yiisoft/yii2: *
This package is not auto-updated.
Last update: 2024-10-02 10:47:45 UTC
README
使用 SMS 平台的 API 发送短信
安装
安装此扩展的首选方式是通过 composer。
运行以下命令:
php composer.phar require liangzoe/yii2-mobilesmser "*"
或者将以下内容添加到你的 composer.json
文件的 require 部分:
"liangzoe/yii2-mobilesmser": "*"
使用方法
- 让我们将以下配置添加到主配置文件中的 Component 部分
'smser' => [
'smser' => [
'class' => 'liangzoe\mobilesmser\TextSmser',
'url' => '',
'username' => '',
'password' => '',
],
],
```use in phpfile
Yii::$app->smser->sendSMS('手机号码', '短信内容');
```
'''reference in the view'''
Countdown with jquery
<script type="text/javascript">
var wait=60;
function time(o) {//o为按钮对象
if (wait == 0) {
o.removeAttribute("disabled");
o.value="免费获取短信动态码";
wait = 60;
} else {
o.setAttribute("disabled", true); //倒计时中,禁止点击按钮
o.value= wait + "秒后重新发送";
wait--;
setTimeout(function() { time(o);}, 1000);
}
</script>