mirror of
https://gitee.com/hotlcc/wechat4j.git
synced 2025-06-29 21:52:46 +08:00
提交代码
This commit is contained in:
parent
1e028d62ed
commit
5db685323f
@ -1049,20 +1049,20 @@ public class Wechat {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public JSONObject sendText(String Content, String ToUserName) {
|
||||
public JSONObject sendText(String content, String toUserName) {
|
||||
BaseRequest BaseRequest = new BaseRequest(wxsid, skey, wxuin);
|
||||
|
||||
String msgId = WechatUtil.createMsgId();
|
||||
String loginUserName = getLoginUserName(false);
|
||||
WxMessage message = new WxMessage();
|
||||
message.setClientMsgId(msgId);
|
||||
message.setContent(Content);
|
||||
message.setContent(content);
|
||||
message.setFromUserName(loginUserName);
|
||||
message.setLocalID(msgId);
|
||||
if (StringUtil.isEmpty(ToUserName)) {
|
||||
if (StringUtil.isEmpty(toUserName)) {
|
||||
message.setToUserName(loginUserName);
|
||||
} else {
|
||||
message.setToUserName(ToUserName);
|
||||
message.setToUserName(toUserName);
|
||||
}
|
||||
message.setType(MsgTypeEnum.TEXT_MSG.getCode());
|
||||
|
||||
@ -1074,50 +1074,50 @@ public class Wechat {
|
||||
/**
|
||||
* 发送文本消息(根据昵称)
|
||||
*
|
||||
* @param Content
|
||||
* @param NickName
|
||||
* @param content
|
||||
* @param nickName
|
||||
* @return
|
||||
*/
|
||||
public JSONObject sendTextToNickName(String Content, String NickName) {
|
||||
if (StringUtil.isEmpty(NickName)) {
|
||||
return sendText(Content, null);
|
||||
public JSONObject sendTextToNickName(String content, String nickName) {
|
||||
if (StringUtil.isEmpty(nickName)) {
|
||||
return sendText(content, null);
|
||||
}
|
||||
|
||||
UserInfo userInfo = getContactByNickName(false, NickName);
|
||||
UserInfo userInfo = getContactByNickName(false, nickName);
|
||||
if (userInfo == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String UserName = userInfo.getUserName();
|
||||
if (StringUtil.isEmpty(UserName)) {
|
||||
String userName = userInfo.getUserName();
|
||||
if (StringUtil.isEmpty(userName)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return sendText(Content, UserName);
|
||||
return sendText(content, userName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送文本消息(根据备注名)
|
||||
*
|
||||
* @param Content
|
||||
* @param RemarkName
|
||||
* @param content
|
||||
* @param remarkName
|
||||
* @return
|
||||
*/
|
||||
public JSONObject sendTextToRemarkName(String Content, String RemarkName) {
|
||||
if (StringUtil.isEmpty(RemarkName)) {
|
||||
return sendText(Content, null);
|
||||
public JSONObject sendTextToRemarkName(String content, String remarkName) {
|
||||
if (StringUtil.isEmpty(remarkName)) {
|
||||
return sendText(content, null);
|
||||
}
|
||||
|
||||
UserInfo userInfo = getContactByRemarkName(false, RemarkName);
|
||||
UserInfo userInfo = getContactByRemarkName(false, remarkName);
|
||||
if (userInfo == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String UserName = userInfo.getUserName();
|
||||
if (StringUtil.isEmpty(UserName)) {
|
||||
String userName = userInfo.getUserName();
|
||||
if (StringUtil.isEmpty(userName)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return sendText(Content, UserName);
|
||||
return sendText(content, userName);
|
||||
}
|
||||
}
|
||||
|
@ -542,6 +542,7 @@ public class WebWeixinApi {
|
||||
paramJson.put("BaseRequest", BaseRequest);
|
||||
paramJson.put("Msg", message);
|
||||
paramJson.put("Scene", 0);
|
||||
System.out.println(paramJson.toJSONString());
|
||||
HttpEntity paramEntity = new StringEntity(paramJson.toJSONString(), Consts.UTF_8);
|
||||
httpPost.setEntity(paramEntity);
|
||||
|
||||
|
@ -2,6 +2,7 @@ package com.hotlcc.wechat4j.model;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -10,15 +11,17 @@ public final class AppInfo {
|
||||
private AppInfo() {
|
||||
}
|
||||
|
||||
private Integer Type;
|
||||
private String AppID;
|
||||
@JSONField(name = "Type")
|
||||
private Integer type;
|
||||
@JSONField(name = "AppID")
|
||||
private String appID;
|
||||
|
||||
public Integer getType() {
|
||||
return Type;
|
||||
return type;
|
||||
}
|
||||
|
||||
public String getAppID() {
|
||||
return AppID;
|
||||
return appID;
|
||||
}
|
||||
|
||||
public static AppInfo valueOf(JSONObject info) {
|
||||
@ -26,8 +29,8 @@ public final class AppInfo {
|
||||
return null;
|
||||
}
|
||||
AppInfo appInfo = new AppInfo();
|
||||
appInfo.Type = info.getInteger("Type");
|
||||
appInfo.AppID = info.getString("AppID");
|
||||
appInfo.type = info.getInteger("Type");
|
||||
appInfo.appID = info.getString("AppID");
|
||||
return appInfo;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.hotlcc.wechat4j.model;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.hotlcc.wechat4j.util.WechatUtil;
|
||||
|
||||
/**
|
||||
@ -9,51 +10,55 @@ public class BaseRequest {
|
||||
public BaseRequest() {
|
||||
}
|
||||
|
||||
public BaseRequest(String DeviceID, String Sid, String Skey, String Uin) {
|
||||
this.DeviceID = DeviceID;
|
||||
this.Sid = Sid;
|
||||
this.Skey = Skey;
|
||||
this.Uin = Uin;
|
||||
public BaseRequest(String deviceID, String sid, String skey, String uin) {
|
||||
this.deviceID = deviceID;
|
||||
this.sid = sid;
|
||||
this.skey = skey;
|
||||
this.uin = uin;
|
||||
}
|
||||
|
||||
public BaseRequest(String Sid, String Skey, String Uin) {
|
||||
this(WechatUtil.createDeviceID(), Sid, Skey, Uin);
|
||||
}
|
||||
|
||||
private String DeviceID;
|
||||
private String Sid;
|
||||
private String Skey;
|
||||
private String Uin;
|
||||
@JSONField(name = "DeviceID")
|
||||
private String deviceID;
|
||||
@JSONField(name = "Sid")
|
||||
private String sid;
|
||||
@JSONField(name = "Skey")
|
||||
private String skey;
|
||||
@JSONField(name = "Uin")
|
||||
private String uin;
|
||||
|
||||
public String getDeviceID() {
|
||||
return DeviceID;
|
||||
return deviceID;
|
||||
}
|
||||
|
||||
public void setDeviceID(String deviceID) {
|
||||
DeviceID = deviceID;
|
||||
deviceID = deviceID;
|
||||
}
|
||||
|
||||
public String getSid() {
|
||||
return Sid;
|
||||
return sid;
|
||||
}
|
||||
|
||||
public void setSid(String sid) {
|
||||
Sid = sid;
|
||||
sid = sid;
|
||||
}
|
||||
|
||||
public String getSkey() {
|
||||
return Skey;
|
||||
return skey;
|
||||
}
|
||||
|
||||
public void setSkey(String skey) {
|
||||
Skey = skey;
|
||||
skey = skey;
|
||||
}
|
||||
|
||||
public String getUin() {
|
||||
return Uin;
|
||||
return uin;
|
||||
}
|
||||
|
||||
public void setUin(String uin) {
|
||||
Uin = uin;
|
||||
uin = uin;
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.hotlcc.wechat4j.model;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -10,145 +11,173 @@ public final class ReceivedMsg {
|
||||
private ReceivedMsg() {
|
||||
}
|
||||
|
||||
private Integer SubMsgType;
|
||||
private Long VoiceLength;
|
||||
private String FileName;
|
||||
private Long ImgHeight;
|
||||
private String ToUserName;
|
||||
private Long HasProductId;
|
||||
private Integer ImgStatus;
|
||||
private String Url;
|
||||
private Integer ImgWidth;
|
||||
private Integer ForwardFlag;
|
||||
private Integer Status;
|
||||
private String Ticket;
|
||||
private RecommendInfo RecommendInfo;
|
||||
private Long CreateTime;
|
||||
private Long NewMsgId;
|
||||
private Integer MsgType;
|
||||
private String EncryFileName;
|
||||
private String MsgId;
|
||||
private Integer StatusNotifyCode;
|
||||
private AppInfo AppInfo;
|
||||
private Integer AppMsgType;
|
||||
private Long PlayLength;
|
||||
private String MediaId;
|
||||
private String Content;
|
||||
private String StatusNotifyUserName;
|
||||
private String FromUserName;
|
||||
private String OriContent;
|
||||
private String FileSize;
|
||||
@JSONField(name = "SubMsgType")
|
||||
private Integer subMsgType;
|
||||
@JSONField(name = "VoiceLength")
|
||||
private Long voiceLength;
|
||||
@JSONField(name = "FileName")
|
||||
private String fileName;
|
||||
@JSONField(name = "ImgHeight")
|
||||
private Long imgHeight;
|
||||
@JSONField(name = "ToUserName")
|
||||
private String toUserName;
|
||||
@JSONField(name = "HasProductId")
|
||||
private Long hasProductId;
|
||||
@JSONField(name = "ImgStatus")
|
||||
private Integer imgStatus;
|
||||
@JSONField(name = "Url")
|
||||
private String url;
|
||||
@JSONField(name = "ImgWidth")
|
||||
private Integer imgWidth;
|
||||
@JSONField(name = "ForwardFlag")
|
||||
private Integer forwardFlag;
|
||||
@JSONField(name = "Status")
|
||||
private Integer status;
|
||||
@JSONField(name = "Ticket")
|
||||
private String ticket;
|
||||
@JSONField(name = "RecommendInfo")
|
||||
private RecommendInfo recommendInfo;
|
||||
@JSONField(name = "CreateTime")
|
||||
private Long createTime;
|
||||
@JSONField(name = "NewMsgId")
|
||||
private Long newMsgId;
|
||||
@JSONField(name = "MsgType")
|
||||
private Integer msgType;
|
||||
@JSONField(name = "EncryFileName")
|
||||
private String encryFileName;
|
||||
@JSONField(name = "MsgId")
|
||||
private String msgId;
|
||||
@JSONField(name = "StatusNotifyCode")
|
||||
private Integer statusNotifyCode;
|
||||
@JSONField(name = "AppInfo")
|
||||
private AppInfo appInfo;
|
||||
@JSONField(name = "AppMsgType")
|
||||
private Integer appMsgType;
|
||||
@JSONField(name = "PlayLength")
|
||||
private Long playLength;
|
||||
@JSONField(name = "MediaId")
|
||||
private String mediaId;
|
||||
@JSONField(name = "Content")
|
||||
private String content;
|
||||
@JSONField(name = "StatusNotifyUserName")
|
||||
private String statusNotifyUserName;
|
||||
@JSONField(name = "FromUserName")
|
||||
private String fromUserName;
|
||||
@JSONField(name = "OriContent")
|
||||
private String oriContent;
|
||||
@JSONField(name = "FileSize")
|
||||
private String fileSize;
|
||||
|
||||
public Integer getSubMsgType() {
|
||||
return SubMsgType;
|
||||
return subMsgType;
|
||||
}
|
||||
|
||||
public Long getVoiceLength() {
|
||||
return VoiceLength;
|
||||
return voiceLength;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return FileName;
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public Long getImgHeight() {
|
||||
return ImgHeight;
|
||||
return imgHeight;
|
||||
}
|
||||
|
||||
public String getToUserName() {
|
||||
return ToUserName;
|
||||
return toUserName;
|
||||
}
|
||||
|
||||
public Long getHasProductId() {
|
||||
return HasProductId;
|
||||
return hasProductId;
|
||||
}
|
||||
|
||||
public Integer getImgStatus() {
|
||||
return ImgStatus;
|
||||
return imgStatus;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return Url;
|
||||
return url;
|
||||
}
|
||||
|
||||
public Integer getImgWidth() {
|
||||
return ImgWidth;
|
||||
return imgWidth;
|
||||
}
|
||||
|
||||
public Integer getForwardFlag() {
|
||||
return ForwardFlag;
|
||||
return forwardFlag;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return Status;
|
||||
return status;
|
||||
}
|
||||
|
||||
public String getTicket() {
|
||||
return Ticket;
|
||||
return ticket;
|
||||
}
|
||||
|
||||
public com.hotlcc.wechat4j.model.RecommendInfo getRecommendInfo() {
|
||||
return RecommendInfo;
|
||||
return recommendInfo;
|
||||
}
|
||||
|
||||
public Long getCreateTime() {
|
||||
return CreateTime;
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public Long getNewMsgId() {
|
||||
return NewMsgId;
|
||||
return newMsgId;
|
||||
}
|
||||
|
||||
public Integer getMsgType() {
|
||||
return MsgType;
|
||||
return msgType;
|
||||
}
|
||||
|
||||
public String getEncryFileName() {
|
||||
return EncryFileName;
|
||||
return encryFileName;
|
||||
}
|
||||
|
||||
public String getMsgId() {
|
||||
return MsgId;
|
||||
return msgId;
|
||||
}
|
||||
|
||||
public Integer getStatusNotifyCode() {
|
||||
return StatusNotifyCode;
|
||||
return statusNotifyCode;
|
||||
}
|
||||
|
||||
public AppInfo getAppInfo() {
|
||||
return AppInfo;
|
||||
return appInfo;
|
||||
}
|
||||
|
||||
public Integer getAppMsgType() {
|
||||
return AppMsgType;
|
||||
return appMsgType;
|
||||
}
|
||||
|
||||
public Long getPlayLength() {
|
||||
return PlayLength;
|
||||
return playLength;
|
||||
}
|
||||
|
||||
public String getMediaId() {
|
||||
return MediaId;
|
||||
return mediaId;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return Content;
|
||||
return content;
|
||||
}
|
||||
|
||||
public String getStatusNotifyUserName() {
|
||||
return StatusNotifyUserName;
|
||||
return statusNotifyUserName;
|
||||
}
|
||||
|
||||
public String getFromUserName() {
|
||||
return FromUserName;
|
||||
return fromUserName;
|
||||
}
|
||||
|
||||
public String getOriContent() {
|
||||
return OriContent;
|
||||
return oriContent;
|
||||
}
|
||||
|
||||
public String getFileSize() {
|
||||
return FileSize;
|
||||
return fileSize;
|
||||
}
|
||||
|
||||
public static ReceivedMsg valueOf(JSONObject msg) {
|
||||
@ -158,33 +187,33 @@ public final class ReceivedMsg {
|
||||
|
||||
ReceivedMsg receivedMsg = new ReceivedMsg();
|
||||
|
||||
receivedMsg.SubMsgType = msg.getInteger("SubMsgType");
|
||||
receivedMsg.VoiceLength = msg.getLong("VoiceLength");
|
||||
receivedMsg.FileName = msg.getString("FileName");
|
||||
receivedMsg.ImgHeight = msg.getLong("ImgHeight");
|
||||
receivedMsg.ToUserName = msg.getString("ToUserName");
|
||||
receivedMsg.HasProductId = msg.getLong("HasProductId");
|
||||
receivedMsg.ImgStatus = msg.getInteger("ImgStatus");
|
||||
receivedMsg.Url = msg.getString("Url");
|
||||
receivedMsg.ImgWidth = msg.getInteger("ImgWidth");
|
||||
receivedMsg.ForwardFlag = msg.getInteger("ForwardFlag");
|
||||
receivedMsg.Status = msg.getInteger("Status");
|
||||
receivedMsg.Ticket = msg.getString("Ticket");
|
||||
receivedMsg.RecommendInfo = com.hotlcc.wechat4j.model.RecommendInfo.valueOf(msg.getJSONObject("RecommendInfo"));
|
||||
receivedMsg.CreateTime = msg.getLong("CreateTime");
|
||||
receivedMsg.NewMsgId = msg.getLong("NewMsgId");
|
||||
receivedMsg.MsgType = msg.getInteger("MsgType");
|
||||
receivedMsg.EncryFileName = msg.getString("EncryFileName");
|
||||
receivedMsg.MsgId = msg.getString("MsgId");
|
||||
receivedMsg.StatusNotifyCode = msg.getInteger("StatusNotifyCode");
|
||||
receivedMsg.AppInfo = com.hotlcc.wechat4j.model.AppInfo.valueOf(msg.getJSONObject("AppInfo"));
|
||||
receivedMsg.PlayLength = msg.getLong("PlayLength");
|
||||
receivedMsg.MediaId = msg.getString("MediaId");
|
||||
receivedMsg.Content = msg.getString("Content");
|
||||
receivedMsg.StatusNotifyUserName = msg.getString("StatusNotifyUserName");
|
||||
receivedMsg.FromUserName = msg.getString("FromUserName");
|
||||
receivedMsg.OriContent = msg.getString("OriContent");
|
||||
receivedMsg.FileSize = msg.getString("FileSize");
|
||||
receivedMsg.subMsgType = msg.getInteger("SubMsgType");
|
||||
receivedMsg.voiceLength = msg.getLong("VoiceLength");
|
||||
receivedMsg.fileName = msg.getString("FileName");
|
||||
receivedMsg.imgHeight = msg.getLong("ImgHeight");
|
||||
receivedMsg.toUserName = msg.getString("ToUserName");
|
||||
receivedMsg.hasProductId = msg.getLong("HasProductId");
|
||||
receivedMsg.imgStatus = msg.getInteger("ImgStatus");
|
||||
receivedMsg.url = msg.getString("Url");
|
||||
receivedMsg.imgWidth = msg.getInteger("ImgWidth");
|
||||
receivedMsg.forwardFlag = msg.getInteger("ForwardFlag");
|
||||
receivedMsg.status = msg.getInteger("Status");
|
||||
receivedMsg.ticket = msg.getString("Ticket");
|
||||
receivedMsg.recommendInfo = com.hotlcc.wechat4j.model.RecommendInfo.valueOf(msg.getJSONObject("RecommendInfo"));
|
||||
receivedMsg.createTime = msg.getLong("CreateTime");
|
||||
receivedMsg.newMsgId = msg.getLong("NewMsgId");
|
||||
receivedMsg.msgType = msg.getInteger("MsgType");
|
||||
receivedMsg.encryFileName = msg.getString("EncryFileName");
|
||||
receivedMsg.msgId = msg.getString("MsgId");
|
||||
receivedMsg.statusNotifyCode = msg.getInteger("StatusNotifyCode");
|
||||
receivedMsg.appInfo = com.hotlcc.wechat4j.model.AppInfo.valueOf(msg.getJSONObject("AppInfo"));
|
||||
receivedMsg.playLength = msg.getLong("PlayLength");
|
||||
receivedMsg.mediaId = msg.getString("MediaId");
|
||||
receivedMsg.content = msg.getString("Content");
|
||||
receivedMsg.statusNotifyUserName = msg.getString("StatusNotifyUserName");
|
||||
receivedMsg.fromUserName = msg.getString("FromUserName");
|
||||
receivedMsg.oriContent = msg.getString("OriContent");
|
||||
receivedMsg.fileSize = msg.getString("FileSize");
|
||||
|
||||
return receivedMsg;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.hotlcc.wechat4j.model;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -10,75 +11,89 @@ public final class RecommendInfo {
|
||||
private RecommendInfo() {
|
||||
}
|
||||
|
||||
private String Ticket;
|
||||
private String UserName;
|
||||
private Integer Sex;
|
||||
private Integer AttrStatus;
|
||||
private String City;
|
||||
private String NickName;
|
||||
private Integer Scene;
|
||||
private String Province;
|
||||
private String Content;
|
||||
private String Alias;
|
||||
private String Signature;
|
||||
private Integer OpCode;
|
||||
private Long QQNum;
|
||||
private Integer VerifyFlag;
|
||||
@JSONField(name = "Ticket")
|
||||
private String ticket;
|
||||
@JSONField(name = "UserName")
|
||||
private String userName;
|
||||
@JSONField(name = "Sex")
|
||||
private Integer sex;
|
||||
@JSONField(name = "AttrStatus")
|
||||
private Integer attrStatus;
|
||||
@JSONField(name = "City")
|
||||
private String city;
|
||||
@JSONField(name = "NickName")
|
||||
private String nickName;
|
||||
@JSONField(name = "Scene")
|
||||
private Integer scene;
|
||||
@JSONField(name = "Province")
|
||||
private String province;
|
||||
@JSONField(name = "Content")
|
||||
private String content;
|
||||
@JSONField(name = "Alias")
|
||||
private String alias;
|
||||
@JSONField(name = "Signature")
|
||||
private String signature;
|
||||
@JSONField(name = "OpCode")
|
||||
private Integer opCode;
|
||||
@JSONField(name = "QQNum")
|
||||
private Long qqNum;
|
||||
@JSONField(name = "VerifyFlag")
|
||||
private Integer verifyFlag;
|
||||
|
||||
public String getTicket() {
|
||||
return Ticket;
|
||||
return ticket;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return UserName;
|
||||
return userName;
|
||||
}
|
||||
|
||||
public Integer getSex() {
|
||||
return Sex;
|
||||
return sex;
|
||||
}
|
||||
|
||||
public Integer getAttrStatus() {
|
||||
return AttrStatus;
|
||||
return attrStatus;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return City;
|
||||
return city;
|
||||
}
|
||||
|
||||
public String getNickName() {
|
||||
return NickName;
|
||||
return nickName;
|
||||
}
|
||||
|
||||
public Integer getScene() {
|
||||
return Scene;
|
||||
return scene;
|
||||
}
|
||||
|
||||
public String getProvince() {
|
||||
return Province;
|
||||
return province;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return Content;
|
||||
return content;
|
||||
}
|
||||
|
||||
public String getAlias() {
|
||||
return Alias;
|
||||
return alias;
|
||||
}
|
||||
|
||||
public String getSignature() {
|
||||
return Signature;
|
||||
return signature;
|
||||
}
|
||||
|
||||
public Integer getOpCode() {
|
||||
return OpCode;
|
||||
return opCode;
|
||||
}
|
||||
|
||||
public Long getQQNum() {
|
||||
return QQNum;
|
||||
return qqNum;
|
||||
}
|
||||
|
||||
public Integer getVerifyFlag() {
|
||||
return VerifyFlag;
|
||||
return verifyFlag;
|
||||
}
|
||||
|
||||
public static RecommendInfo valueOf(JSONObject info) {
|
||||
@ -88,20 +103,20 @@ public final class RecommendInfo {
|
||||
|
||||
RecommendInfo recommendInfo = new RecommendInfo();
|
||||
|
||||
recommendInfo.Ticket = info.getString("Ticket");
|
||||
recommendInfo.UserName = info.getString("UserName");
|
||||
recommendInfo.Sex = info.getInteger("Sex");
|
||||
recommendInfo.AttrStatus = info.getInteger("AttrStatus");
|
||||
recommendInfo.City = info.getString("City");
|
||||
recommendInfo.NickName = info.getString("NickName");
|
||||
recommendInfo.Scene = info.getInteger("Scene");
|
||||
recommendInfo.Province = info.getString("Province");
|
||||
recommendInfo.Content = info.getString("Content");
|
||||
recommendInfo.Alias = info.getString("Alias");
|
||||
recommendInfo.Signature = info.getString("Signature");
|
||||
recommendInfo.OpCode = info.getInteger("OpCode");
|
||||
recommendInfo.QQNum = info.getLong("QQNum");
|
||||
recommendInfo.VerifyFlag = info.getInteger("VerifyFlag");
|
||||
recommendInfo.ticket = info.getString("Ticket");
|
||||
recommendInfo.userName = info.getString("UserName");
|
||||
recommendInfo.sex = info.getInteger("Sex");
|
||||
recommendInfo.attrStatus = info.getInteger("AttrStatus");
|
||||
recommendInfo.city = info.getString("City");
|
||||
recommendInfo.nickName = info.getString("NickName");
|
||||
recommendInfo.scene = info.getInteger("Scene");
|
||||
recommendInfo.province = info.getString("Province");
|
||||
recommendInfo.content = info.getString("Content");
|
||||
recommendInfo.alias = info.getString("Alias");
|
||||
recommendInfo.signature = info.getString("Signature");
|
||||
recommendInfo.opCode = info.getInteger("OpCode");
|
||||
recommendInfo.qqNum = info.getLong("QQNum");
|
||||
recommendInfo.verifyFlag = info.getInteger("VerifyFlag");
|
||||
|
||||
return recommendInfo;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.hotlcc.wechat4j.model;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -13,160 +14,191 @@ public final class UserInfo {
|
||||
private UserInfo() {
|
||||
}
|
||||
|
||||
private Long Uin;
|
||||
private String NickName;
|
||||
private String HeadImgUrl;
|
||||
private Integer ContactFlag;
|
||||
private Integer MemberCount;
|
||||
private List<UserInfo> MemberList;
|
||||
private String RemarkName;
|
||||
private Integer HideInputBarFlag;
|
||||
private Integer Sex;
|
||||
private String Signature;
|
||||
private Integer VerifyFlag;
|
||||
private Long OwnerUin;
|
||||
private String PYInitial;
|
||||
private String PYQuanPin;
|
||||
private String RemarkPYInitial;
|
||||
private String RemarkPYQuanPin;
|
||||
private Integer StarFriend;
|
||||
private Integer AppAccountFlag;
|
||||
private Integer Statues;
|
||||
private Integer AttrStatus;
|
||||
private String Province;
|
||||
private String City;
|
||||
private String Alias;
|
||||
private Integer SnsFlag;
|
||||
private Integer UniFriend;
|
||||
private String DisplayName;
|
||||
private Long ChatRoomId;
|
||||
private String KeyWord;
|
||||
private String EncryChatRoomId;
|
||||
private Integer IsOwner;
|
||||
private String UserName;
|
||||
@JSONField(name = "Uin")
|
||||
private Long uin;
|
||||
@JSONField(name = "NickName")
|
||||
private String nickName;
|
||||
@JSONField(name = "HeadImgUrl")
|
||||
private String headImgUrl;
|
||||
@JSONField(name = "ContactFlag")
|
||||
private Integer contactFlag;
|
||||
@JSONField(name = "MemberCount")
|
||||
private Integer memberCount;
|
||||
@JSONField(name = "MemberList")
|
||||
private List<UserInfo> memberList;
|
||||
@JSONField(name = "RemarkName")
|
||||
private String remarkName;
|
||||
@JSONField(name = "HideInputBarFlag")
|
||||
private Integer hideInputBarFlag;
|
||||
@JSONField(name = "Sex")
|
||||
private Integer sex;
|
||||
@JSONField(name = "Signature")
|
||||
private String signature;
|
||||
@JSONField(name = "VerifyFlag")
|
||||
private Integer verifyFlag;
|
||||
@JSONField(name = "OwnerUin")
|
||||
private Long ownerUin;
|
||||
@JSONField(name = "PYInitial")
|
||||
private String pyInitial;
|
||||
@JSONField(name = "PYQuanPin")
|
||||
private String pyQuanPin;
|
||||
@JSONField(name = "RemarkPYInitial")
|
||||
private String remarkPYInitial;
|
||||
@JSONField(name = "RemarkPYQuanPin")
|
||||
private String remarkPYQuanPin;
|
||||
@JSONField(name = "StarFriend")
|
||||
private Integer starFriend;
|
||||
@JSONField(name = "AppAccountFlag")
|
||||
private Integer appAccountFlag;
|
||||
@JSONField(name = "Statues")
|
||||
private Integer statues;
|
||||
@JSONField(name = "AttrStatus")
|
||||
private Integer attrStatus;
|
||||
@JSONField(name = "Province")
|
||||
private String province;
|
||||
@JSONField(name = "City")
|
||||
private String city;
|
||||
@JSONField(name = "Alias")
|
||||
private String alias;
|
||||
@JSONField(name = "SnsFlag")
|
||||
private Integer snsFlag;
|
||||
@JSONField(name = "UniFriend")
|
||||
private Integer uniFriend;
|
||||
@JSONField(name = "DisplayName")
|
||||
private String displayName;
|
||||
@JSONField(name = "ChatRoomId")
|
||||
private Long chatRoomId;
|
||||
@JSONField(name = "KeyWord")
|
||||
private String keyWord;
|
||||
@JSONField(name = "EncryChatRoomId")
|
||||
private String encryChatRoomId;
|
||||
@JSONField(name = "IsOwner")
|
||||
private Integer isOwner;
|
||||
@JSONField(name = "UserName")
|
||||
private String userName;
|
||||
|
||||
public Long getUin() {
|
||||
return Uin;
|
||||
return uin;
|
||||
}
|
||||
|
||||
public String getNickName() {
|
||||
return NickName;
|
||||
return nickName;
|
||||
}
|
||||
|
||||
public String getHeadImgUrl() {
|
||||
return HeadImgUrl;
|
||||
return headImgUrl;
|
||||
}
|
||||
|
||||
public Integer getContactFlag() {
|
||||
return ContactFlag;
|
||||
return contactFlag;
|
||||
}
|
||||
|
||||
public Integer getMemberCount() {
|
||||
return MemberCount;
|
||||
return memberCount;
|
||||
}
|
||||
|
||||
public List<UserInfo> getMemberList() {
|
||||
return MemberList;
|
||||
return memberList;
|
||||
}
|
||||
|
||||
public String getRemarkName() {
|
||||
return RemarkName;
|
||||
return remarkName;
|
||||
}
|
||||
|
||||
public Integer getHideInputBarFlag() {
|
||||
return HideInputBarFlag;
|
||||
return hideInputBarFlag;
|
||||
}
|
||||
|
||||
public Integer getSex() {
|
||||
return Sex;
|
||||
return sex;
|
||||
}
|
||||
|
||||
public String getSignature() {
|
||||
return Signature;
|
||||
return signature;
|
||||
}
|
||||
|
||||
public Integer getVerifyFlag() {
|
||||
return VerifyFlag;
|
||||
return verifyFlag;
|
||||
}
|
||||
|
||||
public Long getOwnerUin() {
|
||||
return OwnerUin;
|
||||
return ownerUin;
|
||||
}
|
||||
|
||||
public String getPYInitial() {
|
||||
return PYInitial;
|
||||
return pyInitial;
|
||||
}
|
||||
|
||||
public String getPYQuanPin() {
|
||||
return PYQuanPin;
|
||||
return pyQuanPin;
|
||||
}
|
||||
|
||||
public String getRemarkPYInitial() {
|
||||
return RemarkPYInitial;
|
||||
return remarkPYInitial;
|
||||
}
|
||||
|
||||
public String getRemarkPYQuanPin() {
|
||||
return RemarkPYQuanPin;
|
||||
return remarkPYQuanPin;
|
||||
}
|
||||
|
||||
public Integer getStarFriend() {
|
||||
return StarFriend;
|
||||
return starFriend;
|
||||
}
|
||||
|
||||
public Integer getAppAccountFlag() {
|
||||
return AppAccountFlag;
|
||||
return appAccountFlag;
|
||||
}
|
||||
|
||||
public Integer getStatues() {
|
||||
return Statues;
|
||||
return statues;
|
||||
}
|
||||
|
||||
public Integer getAttrStatus() {
|
||||
return AttrStatus;
|
||||
return attrStatus;
|
||||
}
|
||||
|
||||
public String getProvince() {
|
||||
return Province;
|
||||
return province;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return City;
|
||||
return city;
|
||||
}
|
||||
|
||||
public String getAlias() {
|
||||
return Alias;
|
||||
return alias;
|
||||
}
|
||||
|
||||
public Integer getSnsFlag() {
|
||||
return SnsFlag;
|
||||
return snsFlag;
|
||||
}
|
||||
|
||||
public Integer getUniFriend() {
|
||||
return UniFriend;
|
||||
return uniFriend;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return DisplayName;
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public Long getChatRoomId() {
|
||||
return ChatRoomId;
|
||||
return chatRoomId;
|
||||
}
|
||||
|
||||
public String getKeyWord() {
|
||||
return KeyWord;
|
||||
return keyWord;
|
||||
}
|
||||
|
||||
public String getEncryChatRoomId() {
|
||||
return EncryChatRoomId;
|
||||
return encryChatRoomId;
|
||||
}
|
||||
|
||||
public Integer getIsOwner() {
|
||||
return IsOwner;
|
||||
return isOwner;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return UserName;
|
||||
return userName;
|
||||
}
|
||||
|
||||
public static UserInfo valueOf(JSONObject info) {
|
||||
@ -176,37 +208,37 @@ public final class UserInfo {
|
||||
|
||||
UserInfo userInfo = new UserInfo();
|
||||
|
||||
userInfo.Uin = info.getLong("Uin");
|
||||
userInfo.NickName = info.getString("NickName");
|
||||
userInfo.HeadImgUrl = info.getString("HeadImgUrl");
|
||||
userInfo.ContactFlag = info.getInteger("ContactFlag");
|
||||
userInfo.MemberCount = info.getInteger("MemberCount");
|
||||
userInfo.MemberList = valueOf(info.getJSONArray("MemberList"));
|
||||
userInfo.RemarkName = info.getString("RemarkName");
|
||||
userInfo.HideInputBarFlag = info.getInteger("HideInputBarFlag");
|
||||
userInfo.Sex = info.getInteger("Sex");
|
||||
userInfo.Signature = info.getString("Signature");
|
||||
userInfo.VerifyFlag = info.getInteger("VerifyFlag");
|
||||
userInfo.OwnerUin = info.getLong("OwnerUin");
|
||||
userInfo.PYInitial = info.getString("PYInitial");
|
||||
userInfo.PYQuanPin = info.getString("PYQuanPin");
|
||||
userInfo.RemarkPYInitial = info.getString("RemarkPYInitial");
|
||||
userInfo.RemarkPYQuanPin = info.getString("RemarkPYQuanPin");
|
||||
userInfo.StarFriend = info.getInteger("StarFriend");
|
||||
userInfo.AppAccountFlag = info.getInteger("AppAccountFlag");
|
||||
userInfo.Statues = info.getInteger("Statues");
|
||||
userInfo.AttrStatus = info.getInteger("AttrStatus");
|
||||
userInfo.Province = info.getString("Province");
|
||||
userInfo.City = info.getString("City");
|
||||
userInfo.Alias = info.getString("Alias");
|
||||
userInfo.SnsFlag = info.getInteger("SnsFlag");
|
||||
userInfo.UniFriend = info.getInteger("UniFriend");
|
||||
userInfo.DisplayName = info.getString("DisplayName");
|
||||
userInfo.ChatRoomId = info.getLong("ChatRoomId");
|
||||
userInfo.KeyWord = info.getString("KeyWord");
|
||||
userInfo.EncryChatRoomId = info.getString("EncryChatRoomId");
|
||||
userInfo.IsOwner = info.getInteger("IsOwner");
|
||||
userInfo.UserName = info.getString("UserName");
|
||||
userInfo.uin = info.getLong("Uin");
|
||||
userInfo.nickName = info.getString("NickName");
|
||||
userInfo.headImgUrl = info.getString("HeadImgUrl");
|
||||
userInfo.contactFlag = info.getInteger("ContactFlag");
|
||||
userInfo.memberCount = info.getInteger("MemberCount");
|
||||
userInfo.memberList = valueOf(info.getJSONArray("MemberList"));
|
||||
userInfo.remarkName = info.getString("RemarkName");
|
||||
userInfo.hideInputBarFlag = info.getInteger("HideInputBarFlag");
|
||||
userInfo.sex = info.getInteger("Sex");
|
||||
userInfo.signature = info.getString("Signature");
|
||||
userInfo.verifyFlag = info.getInteger("VerifyFlag");
|
||||
userInfo.ownerUin = info.getLong("OwnerUin");
|
||||
userInfo.pyInitial = info.getString("PYInitial");
|
||||
userInfo.pyQuanPin = info.getString("PYQuanPin");
|
||||
userInfo.remarkPYInitial = info.getString("RemarkPYInitial");
|
||||
userInfo.remarkPYQuanPin = info.getString("RemarkPYQuanPin");
|
||||
userInfo.starFriend = info.getInteger("StarFriend");
|
||||
userInfo.appAccountFlag = info.getInteger("AppAccountFlag");
|
||||
userInfo.statues = info.getInteger("Statues");
|
||||
userInfo.attrStatus = info.getInteger("AttrStatus");
|
||||
userInfo.province = info.getString("Province");
|
||||
userInfo.city = info.getString("City");
|
||||
userInfo.alias = info.getString("Alias");
|
||||
userInfo.snsFlag = info.getInteger("SnsFlag");
|
||||
userInfo.uniFriend = info.getInteger("UniFriend");
|
||||
userInfo.displayName = info.getString("DisplayName");
|
||||
userInfo.chatRoomId = info.getLong("ChatRoomId");
|
||||
userInfo.keyWord = info.getString("KeyWord");
|
||||
userInfo.encryChatRoomId = info.getString("EncryChatRoomId");
|
||||
userInfo.isOwner = info.getInteger("IsOwner");
|
||||
userInfo.userName = info.getString("UserName");
|
||||
|
||||
return userInfo;
|
||||
}
|
||||
|
@ -1,54 +1,62 @@
|
||||
package com.hotlcc.wechat4j.model;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
|
||||
/**
|
||||
* 要发送的消息
|
||||
*/
|
||||
public class WxMessage {
|
||||
private String ClientMsgId;
|
||||
private String Content;
|
||||
private String FromUserName;
|
||||
private String LocalID;
|
||||
private String ToUserName;
|
||||
@JSONField(name = "ClientMsgId")
|
||||
private String clientMsgId;
|
||||
@JSONField(name = "Content")
|
||||
private String content;
|
||||
@JSONField(name = "FromUserName")
|
||||
private String fromUserName;
|
||||
@JSONField(name = "LocalID")
|
||||
private String localID;
|
||||
@JSONField(name = "ToUserName")
|
||||
private String toUserName;
|
||||
@JSONField(name = "Type")
|
||||
private Integer type;
|
||||
|
||||
public String getClientMsgId() {
|
||||
return ClientMsgId;
|
||||
return clientMsgId;
|
||||
}
|
||||
|
||||
public void setClientMsgId(String clientMsgId) {
|
||||
ClientMsgId = clientMsgId;
|
||||
clientMsgId = clientMsgId;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return Content;
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
Content = content;
|
||||
content = content;
|
||||
}
|
||||
|
||||
public String getFromUserName() {
|
||||
return FromUserName;
|
||||
return fromUserName;
|
||||
}
|
||||
|
||||
public void setFromUserName(String fromUserName) {
|
||||
FromUserName = fromUserName;
|
||||
fromUserName = fromUserName;
|
||||
}
|
||||
|
||||
public String getLocalID() {
|
||||
return LocalID;
|
||||
return localID;
|
||||
}
|
||||
|
||||
public void setLocalID(String localID) {
|
||||
LocalID = localID;
|
||||
localID = localID;
|
||||
}
|
||||
|
||||
public String getToUserName() {
|
||||
return ToUserName;
|
||||
return toUserName;
|
||||
}
|
||||
|
||||
public void setToUserName(String toUserName) {
|
||||
ToUserName = toUserName;
|
||||
toUserName = toUserName;
|
||||
}
|
||||
|
||||
public Integer getType() {
|
||||
|
@ -1,9 +1,9 @@
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.hotlcc.wechat4j.Wechat;
|
||||
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.util.CommonUtil;
|
||||
|
||||
public class TestClass2 {
|
||||
public static void main(String[] args) {
|
||||
@ -13,14 +13,14 @@ public class TestClass2 {
|
||||
wechat.addReceivedMsgHandler(new ReceivedMsgHandler() {
|
||||
@Override
|
||||
public void handleAllType(Wechat wechat, ReceivedMsg msg) {
|
||||
System.out.println("===收到消息:" + msg.getContent());
|
||||
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();
|
||||
CommonUtil.threadSleep(1000 * 60 * 10);
|
||||
wechat.logout();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user