zoe / yii2-telsmser
SMS extension for yii2
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Type:yii2-extension
Requires
- yiisoft/yii2: *
This package is not auto-updated.
Last update: 2025-07-09 14:31:30 UTC
README
Send text messages with api of SMS platform
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require liangzoe/yii2-mobilesmser "*"
or add
"liangzoe/yii2-mobilesmser": "*"
to the require section of your composer.json
file.
Usage
- Let 's add into Component config in your main config file
'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>