前言:
在数字化时代,自动化工具对提升效率和节省时间至关重要。Gewechat是一个开源项目,帮助开发者通过编程与微信进行互动,自动处理微信消息,创建聊天机器人。使用这个框架,你可以开发各种创新应用,例如企业客服、个人助手,甚至是有趣的社交实验。
项目概况
Gewechat 是 WeChat微信聊天机器人框架的一个插件,主要用于在 云平台上提供微信 API 接口服务,是一个流行的微信开发库,使用 Java 和 GO 编写,专注于通过安全稳定的云平台来实现微信的RPA自动化操作。
可用于以下业务:
- 团队协作:将机器人集成到现有的工作流程中,用于自动发送通知、提醒或收集信息。
- 个人效率:设置定时提醒,自动处理日常事务,如安排日程、支付账单等。
- 数据分析:监控特定话题,收集和分析大量微信数据,用于市场研究或舆情分析。
- 娱乐应用:开发有趣的游戏或挑战,增加互动体验。
项目特点
- 稳定性高:利用 Gewechat 云服务,避免本地客户端的稳定性问题,确保长期可靠运行。
- 快速更新:活跃的社区支持,持续进行优化和更新,确保兼容最新的微信功能。
- 灵活扩展:容易与其他系统集成,可通过插件扩展功能。
- 文档齐全:提供详细的文档和示例代码,帮助开发者快速上手。
- 开源社区:开放源码,鼓励社区贡献,共同推进项目发展。
代码示例:
package api.base;
import com.alibaba.fastjson2.JSONObject;
import util.OkhttpUtil;
/**
* 消息模块
*/
public class MessageApi {
/**
* 发送文字消息
*/
public static JSONObject postText(String appId, String toWxid, String content, String ats) {
JSONObject param = new JSONObject();
param.put("appId", appId);
param.put("toWxid", toWxid);
param.put("content", content);
param.put("ats", ats);
return OkhttpUtil.postJSON("/message/postText", param);
}
/**
* 发送文件消息
*/
public static JSONObject postFile(String appId, String toWxid, String fileUrl, String fileName) {
JSONObject param = new JSONObject();
param.put("appId", appId);
param.put("toWxid", toWxid);
param.put("fileUrl", fileUrl);
param.put("fileName", fileName);
return OkhttpUtil.postJSON("/message/postFile", param);
}
/**
* 发送图片消息
*/
public static JSONObject postImage(String appId, String toWxid, String imgUrl) {
JSONObject param = new JSONObject();
param.put("appId", appId);
param.put("toWxid", toWxid);
param.put("imgUrl", imgUrl);
return OkhttpUtil.postJSON("/message/postImage", param);
}
/**
* 发送语音消息
*/
public static JSONObject postVoice(String appId, String toWxid, String voiceUrl, Integer voiceDuration) {
JSONObject param = new JSONObject();
param.put("appId", appId);
param.put("toWxid", toWxid);
param.put("voiceUrl", voiceUrl);
param.put("voiceDuration", voiceDuration);
return OkhttpUtil.postJSON("/message/postVoice", param);
}
/**
* 发送视频消息
*/
public static JSONObject postVideo(String appId, String toWxid, String videoUrl, String thumbUrl,Integer videoDuration) {
JSONObject param = new JSONObject();
param.put("appId", appId);
param.put("toWxid", toWxid);
param.put("videoUrl", videoUrl);
param.put("thumbUrl", thumbUrl);
param.put("videoDuration", videoDuration);
return OkhttpUtil.postJSON("/message/postVideo", param);
}
/**
* 发送链接消息
*/
public static JSONObject postLink(String appId, String toWxid, String title, String desc, String linkUrl, String thumbUrl) {
JSONObject param = new JSONObject();
param.put("appId", appId);
param.put("toWxid", toWxid);
param.put("title", title);
param.put("desc", desc);
param.put("linkUrl", linkUrl);
param.put("thumbUrl", thumbUrl);
return OkhttpUtil.postJSON("/message/postLink", param);
}
/**
* 发送名片消息
*/
public static JSONObject postNameCard(String appId, String toWxid, String nickName, String nameCardWxid) {
JSONObject param = new JSONObject();
param.put("appId", appId);
param.put("toWxid", toWxid);
param.put("nickName", nickName);
param.put("nameCardWxid", nameCardWxid);
return OkhttpUtil.postJSON("/message/postNameCard", param);
}
/**
* 发送emoji消息
*/
public static JSONObject postEmoji(String appId, String toWxid, String emojiMd5, String emojiSize) {
JSONObject param = new JSONObject();
param.put("appId", appId);
param.put("toWxid", toWxid);
param.put("emojiMd5", emojiMd5);
param.put("emojiSize", emojiSize);
return OkhttpUtil.postJSON("/message/postEmoji", param);
}
/**
* 发送appmsg消息
*/
public static JSONObject postAppMsg(String appId, String toWxid, String appmsg) {
JSONObject param = new JSONObject();
param.put("appId", appId);
param.put("toWxid", toWxid);
param.put("appmsg", appmsg);
return OkhttpUtil.postJSON("/message/postAppMsg", param);
}
/**
* 发送小程序消息
*/
public static JSONObject postMiniApp(String appId, String toWxid, String miniAppId, String displayName, String pagePath, String coverImgUrl, String title, String userName) {
JSONObject param = new JSONObject();
param.put("appId", appId);
param.put("toWxid", toWxid);
param.put("miniAppId", miniAppId);
param.put("displayName", displayName);
param.put("pagePath", pagePath);
param.put("coverImgUrl", coverImgUrl);
param.put("title", title);
param.put("userName", userName);
return OkhttpUtil.postJSON("/message/postMiniApp", param);
}
/**
* 转发文件
*/
public static JSONObject forwardFile(String appId, String toWxid, String xml) {
JSONObject param = new JSONObject();
param.put("appId", appId);
param.put("toWxid", toWxid);
param.put("xml", xml);
return OkhttpUtil.postJSON("/message/forwardFile", param);
}
/**
* 转发图片
*/
public static JSONObject forwardImage(String appId, String toWxid, String xml) {
JSONObject param = new JSONObject();
param.put("appId", appId);
param.put("toWxid", toWxid);
param.put("xml", xml);
return OkhttpUtil.postJSON("/message/forwardImage", param);
}
/**
* 转发视频
*/
public static JSONObject forwardVideo(String appId, String toWxid, String xml) {
JSONObject param = new JSONObject();
param.put("appId", appId);
param.put("toWxid", toWxid);
param.put("xml", xml);
return OkhttpUtil.postJSON("/message/forwardVideo", param);
}
/**
* 转发链接
*/
public static JSONObject forwardUrl(String appId, String toWxid, String xml) {
JSONObject param = new JSONObject();
param.put("appId", appId);
param.put("toWxid", toWxid);
param.put("xml", xml);
return OkhttpUtil.postJSON("/message/forwardUrl", param);
}
/**
* 转发小程序
*/
public static JSONObject forwardMiniApp(String appId, String toWxid, String xml, String coverImgUrl) {
JSONObject param = new JSONObject();
param.put("appId", appId);
param.put("toWxid", toWxid);
param.put("xml", xml);
param.put("coverImgUrl", coverImgUrl);
return OkhttpUtil.postJSON("/message/forwardMiniApp", param);
}
/**
* 撤回消息
*/
public static JSONObject revokeMsg(String appId, String toWxid, String msgId, String newMsgId,String createTime) {
JSONObject param = new JSONObject();
param.put("appId", appId);
param.put("toWxid", toWxid);
param.put("msgId", msgId);
param.put("newMsgId", newMsgId);
param.put("createTime", createTime);
return OkhttpUtil.postJSON("/message/revokeMsg", param);
}
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
- 37.
- 38.
- 39.
- 40.
- 41.
- 42.
- 43.
- 44.
- 45.
- 46.
- 47.
- 48.
- 49.
- 50.
- 51.
- 52.
- 53.
- 54.
- 55.
- 56.
- 57.
- 58.
- 59.
- 60.
- 61.
- 62.
- 63.
- 64.
- 65.
- 66.
- 67.
- 68.
- 69.
- 70.
- 71.
- 72.
- 73.
- 74.
- 75.
- 76.
- 77.
- 78.
- 79.
- 80.
- 81.
- 82.
- 83.
- 84.
- 85.
- 86.
- 87.
- 88.
- 89.
- 90.
- 91.
- 92.
- 93.
- 94.
- 95.
- 96.
- 97.
- 98.
- 99.
- 100.
- 101.
- 102.
- 103.
- 104.
- 105.
- 106.
- 107.
- 108.
- 109.
- 110.
- 111.
- 112.
- 113.
- 114.
- 115.
- 116.
- 117.
- 118.
- 119.
- 120.
- 121.
- 122.
- 123.
- 124.
- 125.
- 126.
- 127.
- 128.
- 129.
- 130.
- 131.
- 132.
- 133.
- 134.
- 135.
- 136.
- 137.
- 138.
- 139.
- 140.
- 141.
- 142.
- 143.
- 144.
- 145.
- 146.
- 147.
- 148.
- 149.
- 150.
- 151.
- 152.
- 153.
- 154.
- 155.
- 156.
- 157.
- 158.
- 159.
- 160.
- 161.
- 162.
- 163.
- 164.
- 165.
- 166.
- 167.
- 168.
- 169.
- 170.
- 171.
- 172.
- 173.
- 174.
- 175.
- 176.
- 177.
- 178.
- 179.
- 180.
- 181.
- 182.
- 183.
- 184.
- 185.
- 186.
- 187.
- 188.
- 189.
- 190.
- 191.
- 192.
- 193.
- 194.
- 195.
- 196.
- 197.
- 198.
- 199.
- 200.
- 201.
- 202.
- 203.
- 204.
- 205.