2023-03-08 11:59:44 +08:00
|
|
|
|
package com.xkrs.straw.utilsnew;
|
2022-06-02 15:10:47 +08:00
|
|
|
|
|
2022-06-02 17:15:31 +08:00
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
2023-03-08 11:21:59 +08:00
|
|
|
|
import static com.xkrs.straw.utilsold.WDHttpClientUtils.sendHttpPost;
|
2022-06-02 17:15:31 +08:00
|
|
|
|
|
2023-03-08 11:59:44 +08:00
|
|
|
|
public class WeiXinMessageUtils {
|
2022-06-02 15:10:47 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 通过udp通信,调用发送微信消息服务,发送微信消息
|
|
|
|
|
*
|
|
|
|
|
* @param wxid 微信id
|
|
|
|
|
* @param text 信息
|
|
|
|
|
* @param type 类型0:文本,1:文档
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
public static void sendMsg(String wxid, String text, Integer type) throws Exception {
|
2022-06-02 17:15:31 +08:00
|
|
|
|
String url = "http://118.24.27.47:10721/winxin_api/msg";
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
|
map.put("wxid", wxid);
|
|
|
|
|
map.put("text", text);
|
|
|
|
|
map.put("type", type);
|
|
|
|
|
sendHttpPost(url, new ObjectMapper().writeValueAsString(map));
|
2022-06-02 15:10:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
|
|
|
sendMsg("18447024917@chatroom", "微信发消息测试", 0);
|
|
|
|
|
}
|
|
|
|
|
}
|