文档中心

新手指南 / 服务介绍 / 接口说明 / 代码示例 / 注意事项

node.js

Node.js是一个可以快速构建网络服务及应用的平台。该平台的构建是基于Chrome's JavaScript runtime,也就是说,实际上它是对GoogleV8引擎(应用于Google Chrome浏览器)进行了封装。

示例中验证部分username固定为api,password格式为key-32位KEY,各位的KEY可在后台短信或语音->触发发送下查看、更改

 

发送短信
发送语音

发送短信

请求
var https = require('https');
var querystring = require('querystring');

var postData = {
    mobile:'13761428267',
    message:'验证码:28261【铁壳测试】'
};

var content = querystring.stringify(postData);

var options = {
    host:'sms-api.luosimao.com',
    path:'/v1/send.json',
    method:'POST',
    auth:'api:key-12312389d10fe16c98896ced5a09945188',
    agent:false,
    rejectUnauthorized : false,
    headers:{
    'Content-Type' : 'application/x-www-form-urlencoded',
    'Content-Length' :content.length
    }
};

var req = https.request(options,function(res){
    res.setEncoding('utf8');
    res.on('data', function (chunk) {
    console.log(JSON.parse(chunk));
    });
    res.on('end',function(){
    console.log('over');
    });
});

    req.write(content);
    req.end();
返回结果
{"error":0,"msg":"ok"}

 

获取余额

请求
var https = require('https');

var options = {
	host:'sms-api.luosimao.com',
	path:'/v1/status.json',
	method:'GET',
	auth:'api:key-123123cd732d929feb06556c063010d1',
        agent:false,
        rejectUnauthorized : false
};

var req = https.request(options,function(res){
	res.setEncoding('utf8');
	res.on('data', function (chunk) {
		console.log(chunk);
	});
});

req.on('error',function(e){
	console.log(e.message);
});

req.end();
返回结果
{"error":0,"deposit":"1119987446"}

 

发送语音

请求
var https = require('https');
var querystring = require('querystring');

var postData = {
    mobile:'13712345678',
    code:'123456'
};

var content = querystring.stringify(postData);

var options = {
    host:'voice-api.luosimao.com',
    path:'/v1/verify.json',
    method:'POST',
    auth:'api:key-12312389d10fe16c98896ced5a09945188',
    agent:false,
    rejectUnauthorized : false,
    headers:{
    'Content-Type' : 'application/x-www-form-urlencoded',
    'Content-Length' :content.length
    }
};

var req = https.request(options,function(res){
    res.setEncoding('utf8');
    res.on('data', function (chunk) {
    console.log(JSON.parse(chunk));
    });
    res.on('end',function(){
    console.log('over');
    });
});

    req.write(content);
    req.end();
返回结果
{"error":0,"msg":"ok"}

 

获取余额

请求
var https = require('https');

var options = {
	host:'voice-api.luosimao.com',
	path:'/v1/status.json',
	method:'GET',
	auth:'api:key-123123cd732d929feb06556c063010d1',
        agent:false,
        rejectUnauthorized : false
};

var req = https.request(options,function(res){
	res.setEncoding('utf8');
	res.on('data', function (chunk) {
		console.log(chunk);
	});
});

req.on('error',function(e){
	console.log(e.message);
});

req.end();
返回结果
{"error":0,"deposit":"1119987446"}

 

微信客服
立即咨询
客服热线:
021-60193106
服务时间:
9:00-18:00
(周日除外)