Skip to content

Instantly share code, notes, and snippets.

@edwardtoday
Created March 13, 2020 09:10
Show Gist options
  • Save edwardtoday/2b5cc4b91bf28fd9b81486656b258b36 to your computer and use it in GitHub Desktop.
Save edwardtoday/2b5cc4b91bf28fd9b81486656b258b36 to your computer and use it in GitHub Desktop.
tasker转发短信到企业微信机器人
// 需要调整到变量
var webhook = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=baffda1c-c922-409e-91ef-***********"
//定义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;
}
//发送消息(文本)
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({
"msgtype": "text",
"text": {
"content": CONTENT
}
});
posthttp(webhook, message);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment