之前的一篇文章《用Tasker实现Android手机短信转发到Telegram或者微信》介绍了用tasker实现手机短信转发的功能,主要是介绍转发到Telegram的方法,对转发到微信的方法一句带过,鉴于某些原因没有详细介绍,本篇简单介绍下如何使用tasker自动转发手机短信到微信上。
短信转发到微信上是使用的企业微信的一项功能:企业微信收到的信息可以同步到微信上,而企业微信有着丰富的可开发性。
整个操作步骤是:1,注册企业微信;2,创建一个应用;3,在tasker中创建配置文件。
- 注册企业微信
- a. 点击这里注册:https://work.weixin.qq.com/wework_admin/register_wx?from=myhome 1分钟时间注册下就行,比较简单。
- b. 注册完成后打开:https://work.weixin.qq.com/wework_admin/frame#profile 复制下网页底部的企业信息中的企业ID备用。
- c. 点击微工作台https://work.weixin.qq.com/wework_admin/frame#profile/wxPlugin看到一个二维码,使用微信扫码关注,这样就可以使企业微信中收到的信息同步到微信上。
- 创建一个应用
- a.点击这里创建 https://work.weixin.qq.com/wework_admin/frame#apps/createApiApp
上传一个应用logo和自定义应用名字,其他默认。 - b.创建后打开:https://work.weixin.qq.com/wework_admin/frame#apps 可以看到在 "应用"中的"自建"里有个应用。点进去打开记录下 AgentId和Secret备用。
- 创建tasker配置文件
下面是创建图示的说明
![](http://upload-images.jianshu.io/upload_images/2483366-1a158b4af8e82b29.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1000/format/webp)
点击加号--新建配置
![](http://upload-images.jianshu.io/upload_images/2483366-7561d0fad704c504.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1000/format/webp)
选择触发类型--事件
![](http://upload-images.jianshu.io/upload_images/2483366-cf131b81601f9dc3.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1000/format/webp)
选择触发条件类型--电话
![](http://upload-images.jianshu.io/upload_images/2483366-89ab6f8e19ba5225.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1000/format/webp)
选择触发内容--收到短信
![](http://upload-images.jianshu.io/upload_images/2483366-6443955402a854a6.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1000/format/webp)
点击返回
![](http://upload-images.jianshu.io/upload_images/2483366-220fc20308bf8523.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1000/format/webp)
新建任务
![](http://upload-images.jianshu.io/upload_images/2483366-f2a38c19dccac0e5.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1000/format/webp)
自定义任务名字(可省略不填)
![](http://upload-images.jianshu.io/upload_images/2483366-15dccde85d960f5e.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1000/format/webp)
点击名字右边的对号
![](http://upload-images.jianshu.io/upload_images/2483366-f21d1f08b45dd6c0.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1000/format/webp)
点击加号--新建操作
![](http://upload-images.jianshu.io/upload_images/2483366-f099575397a486e4.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1000/format/webp)
选择代码
![](http://upload-images.jianshu.io/upload_images/2483366-40ea91bce7e1e5de.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1000/format/webp)
选择JavaScriptlet
![](http://upload-images.jianshu.io/upload_images/2483366-bcea567c6024af75.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1000/format/webp)
在此位置填写代码
![](http://upload-images.jianshu.io/upload_images/2483366-fce23395bf1a4346.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1000/format/webp)
假设填写 flash--好吧,截图截早了
![](http://upload-images.jianshu.io/upload_images/2483366-6ffd568c8ed3e0af.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1000/format/webp)
点击箭头--返回
![](http://upload-images.jianshu.io/upload_images/2483366-318fd11b7dc893a3.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1000/format/webp)
点击对号--保存
![](http://upload-images.jianshu.io/upload_images/2483366-11391db9343f5f39.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1000/format/webp)
这个是完成后看起来的样子
//下面的三个变量值需要修改
var ID = "wwc367de248887ebad";
var SECRET = "KNgBbhHiTo66VSVzqLv0vYCadXE0ndrn5o41xxxB2o4";
var AGENTID = "1000002";
//定义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 + "
时间: " + SMSRT + ", 日期: " + SMSRD + "
短信内容: " + 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);
![](http://upload-images.jianshu.io/upload_images/2483366-2f1507402f769dbd.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1000/format/webp)
在微信中收到的短信内容图示
发送图片到微信的配置也完成了
Tasker配置教程站:Tasker配置教程站
Tasker配置分享站:Tasker配置分享站
原文链接: 用 Tasker 实现收到 Android 手机短信自动转发到微信
或者手机QQ扫描二维码进入。
qq群二维码
附上配置导入链接: