NodeJS

1.安裝

1.運(yùn)行nvm install 6.12.3 64后才能配置npm(安裝重開cmd)
2、windows安裝oracledb
1.set NODE_ORACLEDB_TRACE_INSTALL=TRUE

2.SMPP

1、SMPP Simulator

1、Github
2、視頻教程
3、User Guide
4、發(fā)送長短信,需要選擇【short message in hex format】,【short_message】需要時(shí)16進(jìn)制的,并且前12位為UDH,前綴固定為050003

2、其他

1、相關(guān)資料
2、其他SMPP Simulator,只支持GSM charset,且比較慢
3、 視頻編程參考1 編程參考2
4、SMPP協(xié)議
5、esme(client)和smsc(server)需要互相應(yīng)答 node smpp
6、長短信 長短信編程 字符集

3、node smpp代碼
server端

var smpp = require('smpp');
var server = smpp.createServer(function(session) {
    session.on('bind_transceiver', function(pdu) {
        // we pause the session to prevent further incoming pdu events,
        // untill we authorize the session with some async operation.
        session.pause();
        checkAsyncUserPass(pdu.system_id, pdu.password, function(err) {
            if (err) {
                session.send(pdu.response({
                    command_status: smpp.ESME_RBINDFAIL
                }));
                session.close();
                return;
            }
            console.log('checkAsyncUserPass')
            session.send(pdu.response());
            session.resume();
            
        });
    });
    
    session.on('bind_receiver', function(pdu){ 
     console.log("Srv: received bind_receiver"); 
     session.send(pdu.response()); 
    });
    
    session.on('unbind', function(pdu){ 
     console.log("Srv: received unbind"); 
     session.send(pdu.response()); 
    }); 

    session.on('submit_sm', function(pdu){
     console.log("Srv: received submit_sm, pdu:"); 
     session.send(pdu.response());
        session.deliver_sm({
            source_addr: '17543052055',
            destination_addr: '10086',
            short_message: '050003440301我相信每個(gè)人心中都有一個(gè)小小的心愿。我的心',
            receipted_message_id: '111'
        }, function(pdu) {
            if (pdu.command_status == 0) {
                console.log('deliver_sm_resp');
            }
        }); 
    console.log("session.deliver_sm");
    
    }); 

    session.on('enquire_link', function(pdu){ 
     console.log("Srv: received enquire_link"); 
     session.send(pdu.response()); 
    });    


});
server.listen(8801);


function checkAsyncUserPass(system_id,password,func){
    console.log('bind',system_id);
    func(false);
}

client端

var smpp = require('smpp');
var session = smpp.connect({
    url: 'smpp://127.0.0.1:8801',
    auto_enquire_link_period: 10000
});
session.bind_transceiver({
    system_id: 'XX',
    password: 'XX'
}, function(pdu) {
    
    if (pdu.command_status == 0) {
        // Successfully bound
        session.submit_sm({
            destination_addr: 'DESTINATION NUMBER',
            short_message: 'Hello!'
        }, function(pdu) {
            console.log(pdu.command_status);
            if (pdu.command_status == 0) {
                // Message successfully sent
                console.log(pdu);
                //session.unbind(8801)
                //session.close()
            }
        });
    }
});
session.on('deliver_sm', function(pdu){ 
     console.log(pdu); 
     session.send(pdu.response()); 
}); 

4、vue使用mockjs

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容