网友 a*inhai 说:
*帖最后由 a*inhai 于 2022-7-25 11:23 编辑
实现 IF 短信内容包含“快递” 则转发短信 不包含则不发
**要怎么写
现在这个代码是 什么短信都转发
//定义post方法
function posthttp(**l, data) {
var xhr = new XMLHttpRe*uest();
xhr.addEventListener(&*uot;readystatechange&*uot;, function () {
if (this.readyState === 4) {
flash(this.responseText); //显示返回**,可删除*行
}
});
xhr.open(&*uot;POST&*uot;, **l, false);
xhr.send(data);
ret**n xhr.responseText;
}
//定义get方法
function gethttp(**l) {
var xhr = new XMLHttpRe*uest();
xhr.addEventListener(&*uot;readystatechange&*uot;, function () {
if (this.readyState === 4) {
flash(this.responseText); //显示返回**,可删除*行
}
});
xhr.open(&*uot;GET&*uot;, **l, false);
xhr.send();
ret**n xhr.responseText;
}
//获取token
var gettoken = &*uot;https://*yapi.weixin.**.com/cgi-bin/gettoken?corpid=&*uot; + ID + &*uot;&corpsecret=&*uot; + SECRET;
var ACCESS_TOKEN = **ON.parse(gethttp(gettoken)).acce**_token;
if(SNSRD)
//发送**(文*)
var **SRF = global(‘**SRF’);
var **SRB = global(‘**SRB’);
var **SRT = global(‘**SRT’);
var **SRD = global(‘**SRD’);
var CONTENT = &*uot;发件人: &*uot; + **SRF + &*uot;\n时间: &*uot; + **SRT + &*uot;, 日期: &*uot; + **SRD + &*uot;\n短信内容: &*uot; + **SRB;
var me**age = **ON.st**ngify({
&*uot;touser&*uot;: &*uot;@all&*uot;,
&*uot;msgtype&*uot;: &*uot;text&*uot;,
&*uot;agentid&*uot;: AGENTID,
&*uot;text&*uot;: {
&*uot;content&*uot;: CONTENT
},
&*uot;safe&*uot;: 0
});
var send = &*uot;https://*yapi.weixin.**.com/cgi-bin/me**age/send?acce**_token=&*uot; + ACCESS_TOKEN;
posthttp(send, me**age);
网友 HOH 说:
https://*yapi.weixin.**.com/cgi-bin/me**age/send
网友 *lwz 说:
//定义post方法
function posthttp(**l, data) {
var xhr = new XMLHttpRe*uest();
xhr.addEventListener(&*uot;readystatechange&*uot;, function () {
if (this.readyState === 4) {
flash(this.responseText); //显示返回**,可删除*行
}
});
xhr.open(&*uot;POST&*uot;, **l, false);
xhr.send(data);
ret**n xhr.responseText;
}
//定义get方法
function gethttp(**l) {
var xhr = new XMLHttpRe*uest();
xhr.addEventListener(&*uot;readystatechange&*uot;, function () {
if (this.readyState === 4) {
flash(this.responseText); //显示返回**,可删除*行
}
});
xhr.open(&*uot;GET&*uot;, **l, false);
xhr.send();
ret**n xhr.responseText;
}
//获取token
var gettoken = &*uot;https://*yapi.weixin.**.com/cgi-bin/gettoken?corpid=&*uot; + ID + &*uot;&corpsecret=&*uot; + SECRET;
var ACCESS_TOKEN = **ON.parse(gethttp(gettoken)).acce**_token;
if(SNSRD)
//发送**(文*)
var **SRF = global(‘**SRF’);
var **SRB = global(‘**SRB’);
// **SRB是短信内容? 判断是否包含快递两字
if(**SRB.indexOf(&*uot;快递&*uot; > -1) {
//终止后续 不发短信
ret**n
}
var **SRT = global(‘**SRT’);
var **SRD = global(‘**SRD’);
var CONTENT = &*uot;发件人: &*uot; + **SRF + &*uot;\n时间: &*uot; + **SRT + &*uot;, 日期: &*uot; + **SRD + &*uot;\n短信内容: &*uot; + **SRB;
var me**age = **ON.st**ngify({
&*uot;touser&*uot;: &*uot;@all&*uot;,
&*uot;msgtype&*uot;: &*uot;text&*uot;,
&*uot;agentid&*uot;: AGENTID,
&*uot;text&*uot;: {
&*uot;content&*uot;: CONTENT
},
&*uot;safe&*uot;: 0
});
var send = &*uot;https://*yapi.weixin.**.com/cgi-bin/me**age/send?acce**_token=&*uot; + ACCESS_TOKEN;
posthttp(send, me**age);
网友 tear****s 说:
*帖最后由 tear****s 于 2022-7-25 12:39 编辑
³#是对的
网友 Faxlok 说:
47行整行换成
if(me**age.match(&*uot;快递&*uot;))posthttp(send, me**age);
网友 a*inhai 说:
*lwz 发表于 2022-7-25 11:33
网友 *lwz 说:
a*inhai 发表于 2022-7-25 11:51
Unc**ght SyntaxEr**r: Invalid or unexpected token
贝壳主机网
