1.安装
1.运行
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、发送长短信,需要选择【short message in hex format】,【short_message】需要时16进制的,并且前12位为UDH,前缀固定为050003
2、其他
1、相关资料
2、其他SMPP Simulator,只支持GSM charset,且比较慢
3、 视频编程参考1 编程参考2
4、SMPP协议
5、esme(client)和smsc(server)需要互相应答 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我相信每个人心中都有一个小小的心愿。我的心',
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());
});