Recommend a simple and functional interface to send SMS verification code
1. Install
SDK After downloading the file contains only a zhenzisms.js import directly into the project can be used. download
2. Use
the introduction module
const zhenzismsClient = require('./zhenzisms');复制代码
zhenzisms.js introducing specific address, please replace your actual path
Use pre-application AppId, AppSecret initialization ZhenziSmsClient:
var client = new ZhenzismsClient(apiUrl, '您的榛子云AppId', '您的榛子云AppSecret');复制代码
apiUrl request address, individual developers use sms_developer.zhenzikj.com, enterprise developers use sms.zhenzikj.com , pay attention to protocol prefix http or https do with
AppId, AppSecret as hazelnut cloud messaging development parameters, can be obtained by registering
send messages:
res.then(function(res) {
console.log(res);
});
复制代码
A method for transmitting a single send message
message: message content, such as: Your verification code is: 2233
number: phone number to receive text messages
messageId: that is uniquely identifies the entry of text messages, can not be repeated, the latter can interface to query SMS message by findSmsByMessageId
The result is a string json format, code: sending state, 0 is successful. 0 is a non-transmission failure, the error message can be viewed from data
Download the 60-second countdown in JavaScript plug-in: download
Reproduced in: https: //juejin.im/post/5cfe1b236fb9a07ec56e6d11