NodeJS DEMO


功能說明:該接口要求提前在云片后臺添加模板,提交短信時,系統(tǒng)會自動匹配審核通過的模板,匹配成功任意一個模板即可發(fā)送。系統(tǒng)已提供的默認模板添加簽名后可以直接使用。


// 修改為您的apikey.可在官網(wǎng)(http://www.ssjdyy2.com)登錄后獲取
var https = require("https");
var qs = require("querystring");

var apikey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
// 修改為您要發(fā)送的手機號碼,多個號碼用逗號隔開
var mobile = "xxxxxxxxxxx";
// 修改為您要發(fā)送的短信內(nèi)容
var text = "【云片網(wǎng)】您的驗證碼是1234,5分鐘內(nèi)有效。";
// 指定發(fā)送的模板編號
var tpl_id = 365741;
// 指定發(fā)送模板的內(nèi)容
var tpl_value = { "#code#": "1234", "#min#": "5" };
// 語音短信的內(nèi)容
var code = "1234";
// 查詢賬戶信息https地址
var get_user_info_uri = "/v2/user/get.json";
// 智能匹配模板發(fā)送https地址
var sms_host = "sms.yunpian.com";
var voice_host = "voice.yunpian.com";

send_sms_uri = "/v2/sms/single_send.json";
// 指定模板發(fā)送接口https地址
send_tpl_sms_uri = "/v2/sms/tpl_single_send.json";
// 發(fā)送語音驗證碼接口https地址
send_voice_uri = "/v2/voice/send.json";

query_user_info(get_user_info_uri, apikey);

send_sms(send_sms_uri, apikey, mobile, text);

send_tpl_sms(send_tpl_sms_uri, apikey, mobile, tpl_id, tpl_value);

send_voice_sms(send_voice_uri, apikey, mobile, code);
function query_user_info(uri, apikey) {
  var post_data = {
    apikey: apikey
  }; //這是需要提交的數(shù)據(jù)
  var content = qs.stringify(post_data);
  post(uri, content, sms_host);
}

function send_sms(uri, apikey, mobile, text) {
  var post_data = {
    apikey: apikey,
    mobile: mobile,
    text: text
  }; //這是需要提交的數(shù)據(jù)
  var content = qs.stringify(post_data);
  post(uri, content, sms_host);
}

function send_tpl_sms(uri, apikey, mobile, tpl_id, tpl_value) {
  var post_data = {
    apikey: apikey,
    mobile: mobile,
    tpl_id: tpl_id,
    tpl_value: qs.stringify(tpl_value)
  }; //這是需要提交的數(shù)據(jù)
  var content = qs.stringify(post_data);
  post(uri, content, sms_host);
}
function send_voice_sms(uri, apikey, mobile, code) {
  var post_data = {
    apikey: apikey,
    mobile: mobile,
    code: code
  }; //這是需要提交的數(shù)據(jù)
  var content = qs.stringify(post_data);
  console.log(content);
  post(uri, content, voice_host);
}
function post(uri, content, host) {
  var options = {
    hostname: host,
    port: 443,
    path: uri,
    method: "POST",
    headers: {
      "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
    }
  };
  var req = https.request(options, function(res) {
    // console.log('STATUS: ' + res.statusCode);
    // console.log('HEADERS: ' + JSON.stringify(res.headers));
    res.setEncoding("utf8");
    res.on("data", function(chunk) {
      console.log("BODY: " + chunk);
    });
  });
  //console.log(content);
  req.write(content);

  req.end();
}
特黄人与动人物视频A级毛片,久久婷婷五月色综合蜜芽,亚洲AV永久无码区成人网站,精品无码成人网站久久久久久无码 ,日本动漫爆乳H动漫啪啪免费,成年女人毛片免费视频喷潮,一本之道高清在线观看免费,一级A片无遮挡,18禁美女挤奶水视频免费,欧美牲交A欧美牲交AⅤ电影