mirror of
https://gitee.com/hotlcc/wechat4j.git
synced 2025-12-27 04:19:31 +08:00
提交代码
This commit is contained in:
@@ -4,28 +4,23 @@ import com.hotlcc.wechat4j.api.WebWeixinApi;
|
||||
import com.hotlcc.wechat4j.handler.ReceivedMsgHandler;
|
||||
import com.hotlcc.wechat4j.model.ReceivedMsg;
|
||||
import com.hotlcc.wechat4j.model.UserInfo;
|
||||
import com.hotlcc.wechat4j.model.WxMessage;
|
||||
|
||||
public class TestClass2 {
|
||||
public static void main(String[] args) {
|
||||
// WebWeixinApi api = new WebWeixinApi();
|
||||
// Wechat wechat = new Wechat();
|
||||
// wechat.setWebWeixinApi(api);
|
||||
// wechat.addReceivedMsgHandler(new ReceivedMsgHandler() {
|
||||
// @Override
|
||||
// public void handleAllType(Wechat wechat, ReceivedMsg msg) {
|
||||
// UserInfo contact = wechat.getContactByUserName(false, msg.getFromUserName());
|
||||
// System.out.println(contact.getRemarkName() + ":" + msg.getContent());
|
||||
// if ("李国栋".equals(contact.getRemarkName())) {
|
||||
// JSONObject result = wechat.sendText("你的消息收到了", contact.getUserName());
|
||||
// System.out.println(result);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// wechat.autoLogin();
|
||||
WxMessage message=new WxMessage();
|
||||
message.setToUserName("1");
|
||||
message.setType(1);
|
||||
System.out.println(JSONObject.toJSONString(message));
|
||||
WebWeixinApi api = new WebWeixinApi();
|
||||
Wechat wechat = new Wechat();
|
||||
wechat.setWebWeixinApi(api);
|
||||
wechat.addReceivedMsgHandler(new ReceivedMsgHandler() {
|
||||
@Override
|
||||
public void handleAllType(Wechat wechat, ReceivedMsg msg) {
|
||||
UserInfo contact = wechat.getContactByUserName(false, msg.getFromUserName());
|
||||
System.out.println(contact.getRemarkName() + ":" + msg.getContent());
|
||||
if ("李国栋".equals(contact.getRemarkName())) {
|
||||
JSONObject result = wechat.sendText("你的消息收到了", contact.getUserName());
|
||||
System.out.println(result);
|
||||
}
|
||||
}
|
||||
});
|
||||
wechat.autoLogin();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user