js代码:
//定义post方法
function posthttp(url, data) {
let xhr = new XMLHttpRequest();
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
// flash(this.responseText); //显示返回消息,可删除本行
}
});
xhr.open("POST", url, false);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("X-CMD", "xxxxx");
xhr.send(data);
return xhr.responseText;
}
// 发送消息(文本)
let SMSRF = global('SMSRF');
let SMSRB = global('SMSRB');
let SMSRT = global('SMSRT');
let SMSRD = global('SMSRD');
let CONTENT = "发件人: " + SMSRF + "\n时间: " + SMSRT + ", 日期: " + SMSRD + "\n短信内容: " + SMSRB;
let message = JSON.stringify({
"text": {
"content": CONTENT
},
});
// let send = "http://127.0.0.1:8081/2.0";
let send = "xxxxx.com; // 测试
posthttp(send, message);
亲测 可用!