Nodejs realizes SMS verification function with native mode


Here, I use the SMS interface of SMS suppliers in big cloud market to demonstrate nodejs’s method of realizing sms verification function in native mode. The code is as follows:
`var https = require(‘follow-redirects’).https;
var fs = require(‘fs’);

var qs = require(‘querystring’);

var options = {
‘method’: ‘POST’,
‘hostname’: ‘’,
‘path’: ‘/smsApi/verifyCode’,
‘headers’: {

'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'

‘maxRedirects’: 20

var req = https.request(options, function (res) {
var chunks = [];

res.on(“data”, function (chunk) {



res.on(“end”, function (chunk) {

var body = Buffer.concat(chunks);


res.on(“error”, function (error) {



var postData = qs.stringify({
‘appId’: ’41KYR0EB**’,
‘appKey’: ‘IIWCKKSR7NOQ**’,
‘phone’: ‘1561894**’,
‘templateId’: ‘1043’,
‘variables’: ‘1234’


SMS verification code registration and login can bring users a convenient user registration experience, but it also needs to pay attention to, such as making some security restrictions for the SMS interface, such as the number of requests for the same number is not more than three times in a day; when obtaining the verification code, it is necessary to complete the graphic verification, etc.
NodeJs – Native.js And document description download