本帖最后由 aqinhai 于 2022-7-25 11:23 编辑
实现 IF 短信内容包含“快递” 则转发短信 不包含则不发 JS要怎么写
现在这个代码是 什么短信都转发
- //定义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;
- if(SNSRD)
- //发送消息(文本)
- 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);
复制代码
|