MCPcopy Create free account
hub / github.com/Devo919/Gewechat / MessageApi

Class MessageApi

src/main/java/api/base/MessageApi.java:9–205  ·  view source on GitHub ↗

消息模块

Source from the content-addressed store, hash-verified

7 * 消息模块
8 */
9public class MessageApi {
10
11 /**
12 * 发送文字消息
13 */
14 public static JSONObject postText(String appId, String toWxid, String content, String ats) {
15 JSONObject param = new JSONObject();
16 param.put("appId", appId);
17 param.put("toWxid", toWxid);
18 param.put("content", content);
19 param.put("ats", ats);
20 return OkhttpUtil.postJSON("/message/postText", param);
21 }
22
23 /**
24 * 发送文件消息
25 */
26 public static JSONObject postFile(String appId, String toWxid, String fileUrl, String fileName) {
27 JSONObject param = new JSONObject();
28 param.put("appId", appId);
29 param.put("toWxid", toWxid);
30 param.put("fileUrl", fileUrl);
31 param.put("fileName", fileName);
32 return OkhttpUtil.postJSON("/message/postFile", param);
33 }
34
35 /**
36 * 发送图片消息
37 */
38 public static JSONObject postImage(String appId, String toWxid, String imgUrl) {
39 JSONObject param = new JSONObject();
40 param.put("appId", appId);
41 param.put("toWxid", toWxid);
42 param.put("imgUrl", imgUrl);
43 return OkhttpUtil.postJSON("/message/postImage", param);
44 }
45
46 /**
47 * 发送语音消息
48 */
49 public static JSONObject postVoice(String appId, String toWxid, String voiceUrl, Integer voiceDuration) {
50 JSONObject param = new JSONObject();
51 param.put("appId", appId);
52 param.put("toWxid", toWxid);
53 param.put("voiceUrl", voiceUrl);
54 param.put("voiceDuration", voiceDuration);
55 return OkhttpUtil.postJSON("/message/postVoice", param);
56 }
57
58 /**
59 * 发送视频消息
60 */
61 public static JSONObject postVideo(String appId, String toWxid, String videoUrl, String thumbUrl,Integer videoDuration) {
62 JSONObject param = new JSONObject();
63 param.put("appId", appId);
64 param.put("toWxid", toWxid);
65 param.put("videoUrl", videoUrl);
66 param.put("thumbUrl", thumbUrl);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected