接口文檔

秒賽為開發者提供了詳細的API文檔和代碼示例,幫助開發者快速接入短信平臺

NODE.JS短信接口_NODE.JS短信發送代碼示例

2020-03-10 14:53:05 欄目:代碼示例 查看( )
本文分享NODE.JS短信接口代碼,為方便用戶接入網站/app/各種系統,感興趣的小伙伴們可以參考一下。

var https = require('http');
var qs = require('querystring');
//賬號
var account = '***************';
//密碼
var pswd = '***************';
// 修改為您要發送的手機號碼
var mobile = '***************';
//驗證碼內容
var msg ="【秒賽科技】您的驗證碼是:1234"
// 發送url,驗證碼通知
var url  = "/Api/HttpSendSMYzm.ashx";
//營銷
//url  = "/Api/HttpSendSMYx.ashx";
//語音驗證碼
//url  = "/Api/HttpSendSMYzm.ashx";
 
var sms_host = '139.196.108.241';
//發送驗證碼
send_sms(url,account,pswd,mobile,msg,sms_host);
function send_sms(uri,account,pswd,mobile,msg,sms_host){
    var post_data = {
    'account': account,
    'pswd': pswd,
    'mobile':mobile,
    'msg':msg,
    'needstatusg':'true'
     
    };//這是需要提交的數據
    var postdata = qs.stringify(post_data);
    post(uri,postdata,sms_host);
}
function post(uri,content,host){
    
    var options = {  
        hostname: host,
        port: 8080,  
        path: uri,  
        method: 'POST',  
        headers: {  
            'Content-Type''application/x-www-form-urlencoded;charset=UTF-8',
            'Content-Length' : content.length
        }  
    };
    
    var req = https.request(options, function (res) {        
        res.setEncoding('utf8');
        res.on('data'function (chunk) {
            console.log('BODY: ' + chunk);
        });
    });    
    req.write(content);
    req.end();
}
微信掃一掃

認證、簽名模板審核結果通知

賬號短信余額不足提醒

平臺促銷活動及最新資訊

鄭重申明:①任何個人和或機構在未經過本人同意的情況下,不得擅自轉載或大段引用到網站或者第三方平臺使用,對于擅自盜用文章將通過法律訴訟途徑等一切手段來解決!②部分素材來源于互聯網,如有侵權,請聯系作者刪除!