Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gavinning/alisms
阿里云SMS,阿里云短信验证码发送和验证
https://github.com/gavinning/alisms
alisms aliyun aliyun-sms sms
Last synced: 29 days ago
JSON representation
阿里云SMS,阿里云短信验证码发送和验证
- Host: GitHub
- URL: https://github.com/gavinning/alisms
- Owner: gavinning
- Created: 2020-04-23T12:56:20.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-03-06T09:27:10.000Z (almost 2 years ago)
- Last Synced: 2024-11-27T12:38:41.232Z (about 1 month ago)
- Topics: alisms, aliyun, aliyun-sms, sms
- Language: JavaScript
- Homepage:
- Size: 106 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
Alisms
---
阿里云短信验证码发送和验证### Install
```sh
npm i @4a/alisms
```### Usage
```js
const AliSMS = require('@4a/alisms')
const AliSMSConfig = {
AccessKeyId: "your AccessKeyId",
AccessKeySecret: "your AccessKeySecret",
RegionId: 'your RegionId',
SignName: 'your SignName',
TemplateCode: 'your TemplateCode'
}const Redis = require('ioredis')
const redis = new Redis()const alisms = new AliSMS({ ...AliSMSConfig, redis })
// 创建一个短信验证码
// 模拟发送,测试环境使用该api
alisms.create(telephone)// 创建一个短信验证码
// 真实发送,生产环境使用该api
alisms.publish(telephone)// 验证短信验证码是否合法
alisms.verify(telephone, code)
```### Example
> npm test