Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/yiier/yii2-smser

smser for Yii2
https://github.com/yiier/yii2-smser

yii2-extension yii2-sms yii2-smser

Last synced: about 23 hours ago
JSON representation

smser for Yii2

Awesome Lists containing this project

README

        

sms for Yii2
============
sms for Yii2

[![Latest Stable Version](https://poser.pugx.org/yiier/yii2-smser/v/stable)](https://packagist.org/packages/yiier/yii2-smser)
[![Total Downloads](https://poser.pugx.org/yiier/yii2-smser/downloads)](https://packagist.org/packages/yiier/yii2-smser)
[![Latest Unstable Version](https://poser.pugx.org/yiier/yii2-smser/v/unstable)](https://packagist.org/packages/yiier/yii2-smser)
[![License](https://poser.pugx.org/yiier/yii2-smser/license)](https://packagist.org/packages/yiier/yii2-smser)

Installation
------------

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist yiier/yii2-smser "*"
```

or add

```
"yiier/yii2-smser": "*"
```

to the require section of your `composer.json` file.

Migrations
-----------

Run the following command

```shell
$ php yii migrate --migrationPath=@yiier/smser/migrations/
```

Usage
-----

Once the extension is installed, simply modify your application configuration as follows:

```php
[
'smser' => [
'class' => 'yiier\smser\Smser',
'config' => [
'gateways' => [
// 云片网
'yunpian' => [
'api_key' => 'xxxxxxxxxxxxxxxxxxxxxxxxx',
],
],
]
]
]
];
```

More detail [overtrue/easy-sms 使用](https://github.com/overtrue/easy-sms#%E4%BD%BF%E7%94%A8)

Validator

```php
'Signup'],
];
}
}
```

send code && update code status

```php
smser->send(18688888888, [
'content' => '您的验证码为: 1234',
'template' => 'SMS_001',
'data' => ['code' => 1234, 'usage' => 'Signup'], // or 'data' => ['code' => 1234],
]);

// update used status
\yiier\smser\models\SmsLog::used(18688888888, 1234);
```