nb-cmpp-2
v1.0.7
Published
This is CMPP 2.0 protocol
Downloads
2
Readme
var Client = require("nb-cmpp-2");
var client = new Client({
host : "000.000.000.000", //合同时移动所提供的地址
port : 7890, //机端口号 cmpp2.0默认为7890,cmpp3.0为7891
serviceId: "0000000000", //业务类型 可以是数字、字母和符号的组合10位业务
srcId : "0000000000000" //短信接入码 一般以10开头
});
var SourceAddr = '000000'; //企业ID
var SharedSecret = '000000'; //登录密码
client.on("receive",(mobile,content)=>{
console.log("receive >>>\r\n",mobile,content);
});
client.on("deliver",(res)=>{
console.log("deliver >>>\r\n",res);
});
client.on("error",(err)=>{
console.log("error >>>\r\n",err);
});
client.on("terminated",()=>{
client.connect(SourceAddr,SharedSecret);
});
client.connect(SourceAddr,SharedSecret).then(()=>{
//连上了就可以发短信了
}).catch((err)=>{
console.log(err);
});