level 1
风停山在
楼主
//下面的三个变量值需要修改
var ID = "企业ID";
var SECRET = "企业应用Secret";
var AGENTID = "企业应用AgentId";
//定义post方法
function posthttp(url, data) {
var xhr = new XMLHttpRequest();
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
flash(this.responseText); //显示返回消息,可删除本行
}
});
xhr.open("POST", url, false);
xhr.send(data);
return xhr.responseText;
}
//定义get方法
function gethttp(url) {
var xhr = new XMLHttpRequest();
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
flash(this.responseText); //显示返回消息,可删除本行
}
});
xhr.open("GET", url, false);
xhr.send();
return xhr.responseText;
}
//获取token
var gettoken = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=" + ID + "&corpsecret=" + SECRET;
var ACCESS_TOKEN = JSON.parse(gethttp(gettoken)).access_token;
//发送消息(文本)
var SMSRF = global('SMSRF');
var SMSRB = global('SMSRB');
var SMSRT = global('SMSRT');
var SMSRD = global('SMSRD');
var CONTENT = "发件人: " + SMSRF + "\n时间: " + SMSRT + ", 日期: " + SMSRD + "\n短信内容: " + SMSRB;
var message = JSON.stringify({
"touser": "@all",
"msgtype": "text",
"agentid": AGENTID,
"text": {
"content": CONTENT
},
"safe": 0
});
var send = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=" + ACCESS_TOKEN;
posthttp(send, message);
2023年12月28日 02点12分
1
var ID = "企业ID";
var SECRET = "企业应用Secret";
var AGENTID = "企业应用AgentId";
//定义post方法
function posthttp(url, data) {
var xhr = new XMLHttpRequest();
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
flash(this.responseText); //显示返回消息,可删除本行
}
});
xhr.open("POST", url, false);
xhr.send(data);
return xhr.responseText;
}
//定义get方法
function gethttp(url) {
var xhr = new XMLHttpRequest();
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
flash(this.responseText); //显示返回消息,可删除本行
}
});
xhr.open("GET", url, false);
xhr.send();
return xhr.responseText;
}
//获取token
var gettoken = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=" + ID + "&corpsecret=" + SECRET;
var ACCESS_TOKEN = JSON.parse(gethttp(gettoken)).access_token;
//发送消息(文本)
var SMSRF = global('SMSRF');
var SMSRB = global('SMSRB');
var SMSRT = global('SMSRT');
var SMSRD = global('SMSRD');
var CONTENT = "发件人: " + SMSRF + "\n时间: " + SMSRT + ", 日期: " + SMSRD + "\n短信内容: " + SMSRB;
var message = JSON.stringify({
"touser": "@all",
"msgtype": "text",
"agentid": AGENTID,
"text": {
"content": CONTENT
},
"safe": 0
});
var send = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=" + ACCESS_TOKEN;
posthttp(send, message);
