mirror of
https://gitee.com/hotlcc/wechat4j.git
synced 2025-06-08 19:44:07 +08:00
commit
1ee3100d1c
7
pom.xml
7
pom.xml
@ -79,7 +79,12 @@
|
|||||||
<artifactId>javase</artifactId>
|
<artifactId>javase</artifactId>
|
||||||
<version>3.3.3</version>
|
<version>3.3.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!--lombok简化开发-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>1.16.20</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -28,8 +28,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.PrintWriter;
|
||||||
import java.io.PrintStream;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -183,24 +182,24 @@ public class Wechat {
|
|||||||
/**
|
/**
|
||||||
* 获取uuid(登录时)
|
* 获取uuid(登录时)
|
||||||
*
|
*
|
||||||
* @param ps
|
* @param pw
|
||||||
* @param time
|
* @param time
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private String getWxUuid(PrintStream ps, int time) {
|
private String getWxUuid(PrintWriter pw, int time) {
|
||||||
ps.print("尝试正常方式获取uuid...");
|
pw.print("尝试正常方式获取uuid...");
|
||||||
ps.flush();
|
pw.flush();
|
||||||
|
|
||||||
for (int i = 0; i <= time; i++) {
|
for (int i = 0; i <= time; i++) {
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
ps.print("\t第" + i + "次尝试...");
|
pw.print("\t第" + i + "次尝试...");
|
||||||
ps.flush();
|
pw.flush();
|
||||||
}
|
}
|
||||||
JSONObject result = webWeixinApi.getWxUuid(httpClient);
|
JSONObject result = webWeixinApi.getWxUuid(httpClient);
|
||||||
|
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
ps.println("\t失败:出现异常");
|
pw.println("\t失败:出现异常");
|
||||||
ps.flush();
|
pw.flush();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,23 +207,23 @@ public class Wechat {
|
|||||||
String uuid = result.getString("uuid");
|
String uuid = result.getString("uuid");
|
||||||
if (!"200".equals(code)) {
|
if (!"200".equals(code)) {
|
||||||
String msg = result.getString("msg");
|
String msg = result.getString("msg");
|
||||||
ps.println("\t失败:" + msg);
|
pw.println("\t失败:" + msg);
|
||||||
ps.flush();
|
pw.flush();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtil.isEmpty(uuid)) {
|
if (StringUtil.isEmpty(uuid)) {
|
||||||
ps.print("\t失败");
|
pw.print("\t失败");
|
||||||
if (i == 0 && time > 0) {
|
if (i == 0 && time > 0) {
|
||||||
ps.print(",将重复尝试" + time + "次");
|
pw.print(",将重复尝试" + time + "次");
|
||||||
}
|
}
|
||||||
ps.println();
|
pw.println();
|
||||||
ps.flush();
|
pw.flush();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ps.println("\t成功,值为:" + uuid);
|
pw.println("\t成功,值为:" + uuid);
|
||||||
ps.flush();
|
pw.flush();
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -235,35 +234,35 @@ public class Wechat {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private boolean getAndShowQRCode(PrintStream ps, String uuid, int time) {
|
private boolean getAndShowQRCode(PrintWriter pw, String uuid, int time) {
|
||||||
ps.print("获取二维码...");
|
pw.print("获取二维码...");
|
||||||
ps.flush();
|
pw.flush();
|
||||||
|
|
||||||
for (int i = 0; i <= time; i++) {
|
for (int i = 0; i <= time; i++) {
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
ps.print("\t第" + i + "次尝试...");
|
pw.print("\t第" + i + "次尝试...");
|
||||||
ps.flush();
|
pw.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] data = webWeixinApi.getQR(httpClient, uuid);
|
byte[] data = webWeixinApi.getQR(httpClient, uuid);
|
||||||
|
|
||||||
if (data == null || data.length <= 0) {
|
if (data == null || data.length <= 0) {
|
||||||
ps.print("\t失败");
|
pw.print("\t失败");
|
||||||
if (i == 0 && time > 0) {
|
if (i == 0 && time > 0) {
|
||||||
ps.print(",将重新获取uuid并重复尝试" + time + "次");
|
pw.print(",将重新获取uuid并重复尝试" + time + "次");
|
||||||
}
|
}
|
||||||
ps.println();
|
pw.println();
|
||||||
ps.flush();
|
pw.flush();
|
||||||
getWxUuid(ps, 0);
|
getWxUuid(pw, 0);
|
||||||
|
|
||||||
CommonUtil.threadSleep(2000);
|
CommonUtil.threadSleep(2000);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ps.println("\t成功,请扫描二维码:");
|
pw.println("\t成功,请扫描二维码:");
|
||||||
ps.flush();
|
pw.flush();
|
||||||
ps.println(QRCodeUtil.toCharMatrix(data));
|
pw.println(QRCodeUtil.toCharMatrix(data));
|
||||||
ps.flush();
|
pw.flush();
|
||||||
QRCodeUtil.openQRCodeImage(data);
|
QRCodeUtil.openQRCodeImage(data);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -276,39 +275,39 @@ public class Wechat {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private JSONObject waitForConfirm(PrintStream ps, String uuid) {
|
private JSONObject waitForConfirm(PrintWriter pw, String uuid) {
|
||||||
ps.print("等待手机端扫码...");
|
pw.print("等待手机端扫码...");
|
||||||
ps.flush();
|
pw.flush();
|
||||||
|
|
||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
while (true) {
|
while (true) {
|
||||||
JSONObject result = webWeixinApi.getRedirectUri(httpClient, LoginTipEnum.TIP_0, uuid);
|
JSONObject result = webWeixinApi.getRedirectUri(httpClient, LoginTipEnum.TIP_0, uuid);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
ps.println("\t失败:出现异常");
|
pw.println("\t失败:出现异常");
|
||||||
ps.flush();
|
pw.flush();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String code = result.getString("code");
|
String code = result.getString("code");
|
||||||
if ("408".equals(code)) {
|
if ("408".equals(code)) {
|
||||||
ps.print(".");
|
pw.print(".");
|
||||||
ps.flush();
|
pw.flush();
|
||||||
continue;
|
continue;
|
||||||
} else if ("400".equals(code)) {
|
} else if ("400".equals(code)) {
|
||||||
ps.println("\t失败,二维码失效");
|
pw.println("\t失败,二维码失效");
|
||||||
ps.flush();
|
pw.flush();
|
||||||
return null;
|
return null;
|
||||||
} else if ("201".equals(code)) {
|
} else if ("201".equals(code)) {
|
||||||
if (!flag) {
|
if (!flag) {
|
||||||
ps.println();
|
pw.println();
|
||||||
ps.print("请确认登录...");
|
pw.print("请确认登录...");
|
||||||
ps.flush();
|
pw.flush();
|
||||||
flag = true;
|
flag = true;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
} else if ("200".equals(code)) {
|
} else if ("200".equals(code)) {
|
||||||
ps.println("\t成功,认证完成");
|
pw.println("\t成功,认证完成");
|
||||||
ps.flush();
|
pw.flush();
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
@ -319,21 +318,21 @@ public class Wechat {
|
|||||||
/**
|
/**
|
||||||
* 获取登录认证码(登录时)
|
* 获取登录认证码(登录时)
|
||||||
*/
|
*/
|
||||||
private boolean getLoginCode(PrintStream ps, String redirectUri) {
|
private boolean getLoginCode(PrintWriter pw, String redirectUri) {
|
||||||
ps.print("获取登录认证码...");
|
pw.print("获取登录认证码...");
|
||||||
ps.flush();
|
pw.flush();
|
||||||
|
|
||||||
JSONObject result = webWeixinApi.getLoginCode(httpClient, redirectUri);
|
JSONObject result = webWeixinApi.getLoginCode(httpClient, redirectUri);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
ps.println("\t失败:出现异常");
|
pw.println("\t失败:出现异常");
|
||||||
ps.flush();
|
pw.flush();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String ret = result.getString("ret");
|
String ret = result.getString("ret");
|
||||||
if (!"0".equals(ret)) {
|
if (!"0".equals(ret)) {
|
||||||
ps.println("\t失败:错误的返回码(" + ret + ")");
|
pw.println("\t失败:错误的返回码(" + ret + ")");
|
||||||
ps.flush();
|
pw.flush();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,8 +341,8 @@ public class Wechat {
|
|||||||
skey = result.getString("skey");
|
skey = result.getString("skey");
|
||||||
wxuin = result.getString("wxuin");
|
wxuin = result.getString("wxuin");
|
||||||
|
|
||||||
ps.println("\t成功");
|
pw.println("\t成功");
|
||||||
ps.flush();
|
pw.flush();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -351,37 +350,37 @@ public class Wechat {
|
|||||||
/**
|
/**
|
||||||
* push方式获取uuid(登录时)
|
* push方式获取uuid(登录时)
|
||||||
*
|
*
|
||||||
* @param ps
|
* @param pw
|
||||||
* @param wxuin
|
* @param wxuin
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private String getWxUuid(PrintStream ps, String wxuin) {
|
private String getWxUuid(PrintWriter pw, String wxuin) {
|
||||||
ps.print("尝试push方式获取uuid...");
|
pw.print("尝试push方式获取uuid...");
|
||||||
ps.flush();
|
pw.flush();
|
||||||
|
|
||||||
JSONObject result = webWeixinApi.pushLogin(httpClient, urlVersion, wxuin);
|
JSONObject result = webWeixinApi.pushLogin(httpClient, urlVersion, wxuin);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
ps.println("\t失败:出现异常");
|
pw.println("\t失败:出现异常");
|
||||||
ps.flush();
|
pw.flush();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String ret = result.getString("ret");
|
String ret = result.getString("ret");
|
||||||
if (!"0".equals(ret)) {
|
if (!"0".equals(ret)) {
|
||||||
ps.println("\t失败:错误的返回码(" + ret + ")");
|
pw.println("\t失败:错误的返回码(" + ret + ")");
|
||||||
ps.flush();
|
pw.flush();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String uuid = result.getString("uuid");
|
String uuid = result.getString("uuid");
|
||||||
if (StringUtil.isEmpty(uuid)) {
|
if (StringUtil.isEmpty(uuid)) {
|
||||||
ps.println("\t失败:空值");
|
pw.println("\t失败:空值");
|
||||||
ps.flush();
|
pw.flush();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
ps.println("\t成功,值为:" + uuid);
|
pw.println("\t成功,值为:" + uuid);
|
||||||
ps.flush();
|
pw.flush();
|
||||||
|
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
@ -418,30 +417,30 @@ public class Wechat {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private boolean wxInitWithRetry(PrintStream ps, int time) {
|
private boolean wxInitWithRetry(PrintWriter pw, int time) {
|
||||||
ps.print("正在初始化数据...");
|
pw.print("正在初始化数据...");
|
||||||
ps.flush();
|
pw.flush();
|
||||||
|
|
||||||
for (int i = 0; i <= time; i++) {
|
for (int i = 0; i <= time; i++) {
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
ps.print("\t第" + i + "次尝试...");
|
pw.print("\t第" + i + "次尝试...");
|
||||||
ps.flush();
|
pw.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wxInit()) {
|
if (!wxInit()) {
|
||||||
ps.print("\t失败");
|
pw.print("\t失败");
|
||||||
if (i == 0 && time > 0) {
|
if (i == 0 && time > 0) {
|
||||||
ps.print(",将重复尝试" + time + "次");
|
pw.print(",将重复尝试" + time + "次");
|
||||||
}
|
}
|
||||||
ps.println();
|
pw.println();
|
||||||
ps.flush();
|
pw.flush();
|
||||||
|
|
||||||
CommonUtil.threadSleep(2000);
|
CommonUtil.threadSleep(2000);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ps.println("\t成功");
|
pw.println("\t成功");
|
||||||
ps.flush();
|
pw.flush();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -480,18 +479,15 @@ public class Wechat {
|
|||||||
/**
|
/**
|
||||||
* 自动登录
|
* 自动登录
|
||||||
*/
|
*/
|
||||||
public boolean autoLogin(OutputStream os, boolean tryPushLogin) {
|
public boolean autoLogin(PrintWriter pw, boolean tryPushLogin) {
|
||||||
// 0、获取消息打印流
|
// 0、获取消息打印流
|
||||||
PrintStream ps = null;
|
if (pw == null) {
|
||||||
if (os != null) {
|
pw = new PrintWriter(System.out);
|
||||||
ps = new PrintStream(os);
|
|
||||||
} else {
|
|
||||||
ps = System.out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1、判断是否已经登录
|
// 1、判断是否已经登录
|
||||||
if (isOnline) {
|
if (isOnline) {
|
||||||
ps.println("当前已是登录状态,无需登录");
|
pw.println("当前已是登录状态,无需登录");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -502,45 +498,45 @@ public class Wechat {
|
|||||||
// 2.1、获取uuid
|
// 2.1、获取uuid
|
||||||
String uuid = null;
|
String uuid = null;
|
||||||
if (tryPushLogin && StringUtil.isNotEmpty(wxuin)) {
|
if (tryPushLogin && StringUtil.isNotEmpty(wxuin)) {
|
||||||
uuid = getWxUuid(ps, wxuin);
|
uuid = getWxUuid(pw, wxuin);
|
||||||
}
|
}
|
||||||
if (StringUtil.isEmpty(uuid)) {
|
if (StringUtil.isEmpty(uuid)) {
|
||||||
uuid = getWxUuid(ps, time);
|
uuid = getWxUuid(pw, time);
|
||||||
}
|
}
|
||||||
if (StringUtil.isEmpty(uuid)) {
|
if (StringUtil.isEmpty(uuid)) {
|
||||||
ps.println("无法获取uuid,登录不成功");
|
pw.println("无法获取uuid,登录不成功");
|
||||||
ps.flush();
|
pw.flush();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// 2.2、获取并显示二维码
|
// 2.2、获取并显示二维码
|
||||||
if (!getAndShowQRCode(ps, uuid, time)) {
|
if (!getAndShowQRCode(pw, uuid, time)) {
|
||||||
ps.println("无法获取二维码,登录不成功");
|
pw.println("无法获取二维码,登录不成功");
|
||||||
ps.flush();
|
pw.flush();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// 2.3、等待确认
|
// 2.3、等待确认
|
||||||
result = waitForConfirm(ps, uuid);
|
result = waitForConfirm(pw, uuid);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
ps.println("手机端认证失败,登录不成功");
|
pw.println("手机端认证失败,登录不成功");
|
||||||
ps.flush();
|
pw.flush();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
urlVersion = result.getString("urlVersion");
|
urlVersion = result.getString("urlVersion");
|
||||||
// 2.4、获取登录认证码
|
// 2.4、获取登录认证码
|
||||||
if (!getLoginCode(ps, result.getString("redirectUri"))) {
|
if (!getLoginCode(pw, result.getString("redirectUri"))) {
|
||||||
ps.println("无法获取登录认证码,登录不成功");
|
pw.println("无法获取登录认证码,登录不成功");
|
||||||
ps.flush();
|
pw.flush();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3、初始化数据
|
// 3、初始化数据
|
||||||
if (!wxInitWithRetry(ps, time)) {
|
if (!wxInitWithRetry(pw, time)) {
|
||||||
ps.println("初始化数据失败,请重新登录");
|
pw.println("初始化数据失败,请重新登录");
|
||||||
ps.flush();
|
pw.flush();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ps.println("微信登录成功,欢迎你:" + getLoginUserNickName(false));
|
pw.println("微信登录成功,欢迎你:" + getLoginUserNickName(false));
|
||||||
ps.flush();
|
pw.flush();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
isOnlineLock.lock();
|
isOnlineLock.lock();
|
||||||
@ -569,17 +565,21 @@ public class Wechat {
|
|||||||
* 退出登录
|
* 退出登录
|
||||||
*/
|
*/
|
||||||
public void logout(boolean clearAllLoginInfo) {
|
public void logout(boolean clearAllLoginInfo) {
|
||||||
try {
|
if (isOnline) {
|
||||||
isOnlineLock.lock();
|
try {
|
||||||
|
isOnlineLock.lock();
|
||||||
|
|
||||||
webWeixinApi.logout(httpClient, urlVersion, new BaseRequest(wxsid, skey, wxuin));
|
if (isOnline) {
|
||||||
isOnline = false;
|
webWeixinApi.logout(httpClient, urlVersion, new BaseRequest(wxsid, skey, wxuin));
|
||||||
|
isOnline = false;
|
||||||
|
|
||||||
if (clearAllLoginInfo) {
|
if (clearAllLoginInfo) {
|
||||||
clearAllLoginInfo();
|
clearAllLoginInfo();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
isOnlineLock.unlock();
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
isOnlineLock.unlock();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -640,7 +640,6 @@ public class Wechat {
|
|||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//API调用异常导致退出
|
|
||||||
JSONObject result = webWeixinApi.syncCheck(httpClient, urlVersion, new BaseRequest(wxsid, skey, wxuin), getSyncKeyList(false));
|
JSONObject result = webWeixinApi.syncCheck(httpClient, urlVersion, new BaseRequest(wxsid, skey, wxuin), getSyncKeyList(false));
|
||||||
logger.debug("微信同步监听心跳返回数据:{}", result);
|
logger.debug("微信同步监听心跳返回数据:{}", result);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
@ -743,7 +742,7 @@ public class Wechat {
|
|||||||
try {
|
try {
|
||||||
SelectorEnum e = SelectorEnum.valueOf(selector);
|
SelectorEnum e = SelectorEnum.valueOf(selector);
|
||||||
if (e == null) {
|
if (e == null) {
|
||||||
logger.warn("Cannot process selector for error selector {}", selector);
|
logger.warn("Cannot process unknow selector {}", selector);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -755,6 +754,8 @@ public class Wechat {
|
|||||||
break;
|
break;
|
||||||
case SELECTOR_4:
|
case SELECTOR_4:
|
||||||
break;
|
break;
|
||||||
|
case SELECTOR_6:
|
||||||
|
break;
|
||||||
case SELECTOR_7:
|
case SELECTOR_7:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -813,36 +814,24 @@ public class Wechat {
|
|||||||
*/
|
*/
|
||||||
private void processNewMsg(JSONArray AddMsgList) {
|
private void processNewMsg(JSONArray AddMsgList) {
|
||||||
try {
|
try {
|
||||||
if (AddMsgList != null && !AddMsgList.isEmpty()) {
|
if (AddMsgList == null || AddMsgList.isEmpty()) {
|
||||||
int len = AddMsgList.size();
|
|
||||||
logger.debug("收到{}条新消息", len);
|
|
||||||
for (int i = 0; i < len; i++) {
|
|
||||||
JSONObject AddMsg = AddMsgList.getJSONObject(i);
|
|
||||||
processNewMsg(AddMsg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("Execute processNewMsg error.", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void processNewMsg(JSONObject AddMsg) {
|
|
||||||
try {
|
|
||||||
ReceivedMsg msg = ReceivedMsg.valueOf(AddMsg);
|
|
||||||
processNewMsg(msg);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("Execute processNewMsg error.", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void processNewMsg(ReceivedMsg msg) {
|
|
||||||
try {
|
|
||||||
if (receivedMsgHandlers == null) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (ReceivedMsgHandler handler : receivedMsgHandlers) {
|
|
||||||
if (handler != null) {
|
int len = AddMsgList.size();
|
||||||
processNewMsg(msg, handler);
|
logger.debug("收到{}条新消息", len);
|
||||||
|
|
||||||
|
if (receivedMsgHandlers == null || receivedMsgHandlers.isEmpty()) {
|
||||||
|
logger.warn("收到{}条新消息,但没有配置消息处理器", len);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<ReceivedMsg> receivedMsgList = ReceivedMsg.valueOf(AddMsgList);
|
||||||
|
for (ReceivedMsg receivedMsg : receivedMsgList) {
|
||||||
|
for (ReceivedMsgHandler handler : receivedMsgHandlers) {
|
||||||
|
if (handler != null) {
|
||||||
|
processNewMsg(receivedMsg, handler);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -852,11 +841,9 @@ public class Wechat {
|
|||||||
|
|
||||||
private void processNewMsg(ReceivedMsg msg, ReceivedMsgHandler handler) {
|
private void processNewMsg(ReceivedMsg msg, ReceivedMsgHandler handler) {
|
||||||
try {
|
try {
|
||||||
if (handler != null) {
|
handler.handleAllType(wechat, msg);
|
||||||
handler.handleAllType(wechat, msg);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
logger.error("Execute processNewMsg error.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -897,6 +884,10 @@ public class Wechat {
|
|||||||
return loginUser;
|
return loginUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UserInfo getLoginUser() {
|
||||||
|
return getLoginUser(false);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取登录用户名
|
* 获取登录用户名
|
||||||
*
|
*
|
||||||
@ -910,6 +901,10 @@ public class Wechat {
|
|||||||
return loginUser.getUserName();
|
return loginUser.getUserName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getLoginUserName() {
|
||||||
|
return getLoginUserName(false);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取登录用户的昵称
|
* 获取登录用户的昵称
|
||||||
*
|
*
|
||||||
@ -923,6 +918,10 @@ public class Wechat {
|
|||||||
return loginUser.getNickName();
|
return loginUser.getNickName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getLoginUserNickName() {
|
||||||
|
return getLoginUserNickName(false);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取SyncKey
|
* 获取SyncKey
|
||||||
*
|
*
|
||||||
@ -1011,15 +1010,19 @@ public class Wechat {
|
|||||||
return contactList;
|
return contactList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<UserInfo> getContactList() {
|
||||||
|
return getContactList(false);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据UserName获取联系人信息
|
* 根据UserName获取联系人信息
|
||||||
*
|
*
|
||||||
* @param update
|
* @param update
|
||||||
* @param UserName
|
* @param userName
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public UserInfo getContactByUserName(boolean update, String UserName) {
|
public UserInfo getContactByUserName(boolean update, String userName) {
|
||||||
if (StringUtil.isEmpty(UserName)) {
|
if (StringUtil.isEmpty(userName)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1033,7 +1036,7 @@ public class Wechat {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UserName.equals(userInfo.getUserName())) {
|
if (userName.equals(userInfo.getUserName())) {
|
||||||
return userInfo;
|
return userInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1041,15 +1044,19 @@ public class Wechat {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UserInfo getContactByUserName(String userName) {
|
||||||
|
return getContactByUserName(false, userName);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据NickName获取联系人信息
|
* 根据NickName获取联系人信息
|
||||||
*
|
*
|
||||||
* @param update
|
* @param update
|
||||||
* @param NickName
|
* @param nickName
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public UserInfo getContactByNickName(boolean update, String NickName) {
|
public UserInfo getContactByNickName(boolean update, String nickName) {
|
||||||
if (StringUtil.isEmpty(NickName)) {
|
if (StringUtil.isEmpty(nickName)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1063,7 +1070,7 @@ public class Wechat {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NickName.equals(userInfo.getNickName())) {
|
if (nickName.equals(userInfo.getNickName())) {
|
||||||
return userInfo;
|
return userInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1071,15 +1078,19 @@ public class Wechat {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UserInfo getContactByNickName(String nickName) {
|
||||||
|
return getContactByNickName(false, nickName);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据RemarkName获取联系人信息
|
* 根据RemarkName获取联系人信息
|
||||||
*
|
*
|
||||||
* @param update
|
* @param update
|
||||||
* @param RemarkName
|
* @param remarkName
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public UserInfo getContactByRemarkName(boolean update, String RemarkName) {
|
public UserInfo getContactByRemarkName(boolean update, String remarkName) {
|
||||||
if (StringUtil.isEmpty(RemarkName)) {
|
if (StringUtil.isEmpty(remarkName)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1093,7 +1104,7 @@ public class Wechat {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RemarkName.equals(userInfo.getRemarkName())) {
|
if (remarkName.equals(userInfo.getRemarkName())) {
|
||||||
return userInfo;
|
return userInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1101,6 +1112,10 @@ public class Wechat {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UserInfo getContactByRemarkName(String remarkName) {
|
||||||
|
return getContactByRemarkName(false, remarkName);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送文本消息
|
* 发送文本消息
|
||||||
*
|
*
|
||||||
|
@ -81,7 +81,7 @@ public class WebWeixinApi {
|
|||||||
JSONObject result = new JSONObject();
|
JSONObject result = new JSONObject();
|
||||||
result.put("code", code);
|
result.put("code", code);
|
||||||
if (!"200".equals(code)) {
|
if (!"200".equals(code)) {
|
||||||
result.put("msg", "返回code错误,请确认appid是否有效");
|
result.put("msg", "错误代码(" + code + "),请确认appid是否有效");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -405,8 +405,8 @@ public class WebWeixinApi {
|
|||||||
.render();
|
.render();
|
||||||
|
|
||||||
HttpGet httpGet = new HttpGet(url);
|
HttpGet httpGet = new HttpGet(url);
|
||||||
RequestConfig config = RequestConfig.custom().
|
RequestConfig config = RequestConfig.custom()
|
||||||
setRedirectsEnabled(false)
|
.setRedirectsEnabled(false)
|
||||||
.build();
|
.build();
|
||||||
httpGet.setConfig(config);
|
httpGet.setConfig(config);
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ public enum SelectorEnum {
|
|||||||
SELECTOR_0(0, "正常"),
|
SELECTOR_0(0, "正常"),
|
||||||
SELECTOR_2(2, "有新消息"),
|
SELECTOR_2(2, "有新消息"),
|
||||||
SELECTOR_4(4, "目前发现修改了联系人备注会出现"),
|
SELECTOR_4(4, "目前发现修改了联系人备注会出现"),
|
||||||
|
SELECTOR_6(6, "目前不知道代表什么"),
|
||||||
SELECTOR_7(7, "手机操作了微信");
|
SELECTOR_7(7, "手机操作了微信");
|
||||||
|
|
||||||
private int code;
|
private int code;
|
||||||
|
@ -3,10 +3,12 @@ package com.hotlcc.wechat4j.model;
|
|||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.alibaba.fastjson.annotation.JSONField;
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@Getter
|
||||||
public final class AppInfo {
|
public final class AppInfo {
|
||||||
private AppInfo() {
|
private AppInfo() {
|
||||||
}
|
}
|
||||||
@ -16,14 +18,6 @@ public final class AppInfo {
|
|||||||
@JSONField(name = "AppID")
|
@JSONField(name = "AppID")
|
||||||
private String appID;
|
private String appID;
|
||||||
|
|
||||||
public Integer getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAppID() {
|
|
||||||
return appID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AppInfo valueOf(JSONObject info) {
|
public static AppInfo valueOf(JSONObject info) {
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -2,10 +2,14 @@ package com.hotlcc.wechat4j.model;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.annotation.JSONField;
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
import com.hotlcc.wechat4j.util.WechatUtil;
|
import com.hotlcc.wechat4j.util.WechatUtil;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 基本请求模型
|
* 基本请求模型
|
||||||
*/
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
public class BaseRequest {
|
public class BaseRequest {
|
||||||
public BaseRequest() {
|
public BaseRequest() {
|
||||||
}
|
}
|
||||||
@ -29,36 +33,4 @@ public class BaseRequest {
|
|||||||
private String skey;
|
private String skey;
|
||||||
@JSONField(name = "Uin")
|
@JSONField(name = "Uin")
|
||||||
private String uin;
|
private String uin;
|
||||||
|
|
||||||
public String getDeviceID() {
|
|
||||||
return deviceID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDeviceID(String deviceID) {
|
|
||||||
deviceID = deviceID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSid() {
|
|
||||||
return sid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSid(String sid) {
|
|
||||||
sid = sid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSkey() {
|
|
||||||
return skey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSkey(String skey) {
|
|
||||||
skey = skey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUin() {
|
|
||||||
return uin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUin(String uin) {
|
|
||||||
uin = uin;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,12 @@ package com.hotlcc.wechat4j.model;
|
|||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.alibaba.fastjson.annotation.JSONField;
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@Getter
|
||||||
public final class ReceivedMsg {
|
public final class ReceivedMsg {
|
||||||
private ReceivedMsg() {
|
private ReceivedMsg() {
|
||||||
}
|
}
|
||||||
@ -68,118 +70,6 @@ public final class ReceivedMsg {
|
|||||||
@JSONField(name = "FileSize")
|
@JSONField(name = "FileSize")
|
||||||
private String fileSize;
|
private String fileSize;
|
||||||
|
|
||||||
public Integer getSubMsgType() {
|
|
||||||
return subMsgType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getVoiceLength() {
|
|
||||||
return voiceLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFileName() {
|
|
||||||
return fileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getImgHeight() {
|
|
||||||
return imgHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getToUserName() {
|
|
||||||
return toUserName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getHasProductId() {
|
|
||||||
return hasProductId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getImgStatus() {
|
|
||||||
return imgStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUrl() {
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getImgWidth() {
|
|
||||||
return imgWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getForwardFlag() {
|
|
||||||
return forwardFlag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getStatus() {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTicket() {
|
|
||||||
return ticket;
|
|
||||||
}
|
|
||||||
|
|
||||||
public com.hotlcc.wechat4j.model.RecommendInfo getRecommendInfo() {
|
|
||||||
return recommendInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getCreateTime() {
|
|
||||||
return createTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getNewMsgId() {
|
|
||||||
return newMsgId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getMsgType() {
|
|
||||||
return msgType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEncryFileName() {
|
|
||||||
return encryFileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMsgId() {
|
|
||||||
return msgId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getStatusNotifyCode() {
|
|
||||||
return statusNotifyCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AppInfo getAppInfo() {
|
|
||||||
return appInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getAppMsgType() {
|
|
||||||
return appMsgType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getPlayLength() {
|
|
||||||
return playLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMediaId() {
|
|
||||||
return mediaId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getContent() {
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getStatusNotifyUserName() {
|
|
||||||
return statusNotifyUserName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFromUserName() {
|
|
||||||
return fromUserName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getOriContent() {
|
|
||||||
return oriContent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFileSize() {
|
|
||||||
return fileSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ReceivedMsg valueOf(JSONObject msg) {
|
public static ReceivedMsg valueOf(JSONObject msg) {
|
||||||
if (msg == null) {
|
if (msg == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -3,10 +3,12 @@ package com.hotlcc.wechat4j.model;
|
|||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.alibaba.fastjson.annotation.JSONField;
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@Getter
|
||||||
public final class RecommendInfo {
|
public final class RecommendInfo {
|
||||||
private RecommendInfo() {
|
private RecommendInfo() {
|
||||||
}
|
}
|
||||||
@ -40,62 +42,6 @@ public final class RecommendInfo {
|
|||||||
@JSONField(name = "VerifyFlag")
|
@JSONField(name = "VerifyFlag")
|
||||||
private Integer verifyFlag;
|
private Integer verifyFlag;
|
||||||
|
|
||||||
public String getTicket() {
|
|
||||||
return ticket;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUserName() {
|
|
||||||
return userName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getSex() {
|
|
||||||
return sex;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getAttrStatus() {
|
|
||||||
return attrStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCity() {
|
|
||||||
return city;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNickName() {
|
|
||||||
return nickName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getScene() {
|
|
||||||
return scene;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getProvince() {
|
|
||||||
return province;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getContent() {
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAlias() {
|
|
||||||
return alias;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSignature() {
|
|
||||||
return signature;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getOpCode() {
|
|
||||||
return opCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getQQNum() {
|
|
||||||
return qqNum;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getVerifyFlag() {
|
|
||||||
return verifyFlag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static RecommendInfo valueOf(JSONObject info) {
|
public static RecommendInfo valueOf(JSONObject info) {
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -3,6 +3,7 @@ package com.hotlcc.wechat4j.model;
|
|||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.alibaba.fastjson.annotation.JSONField;
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -10,6 +11,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* 微信用户信息
|
* 微信用户信息
|
||||||
*/
|
*/
|
||||||
|
@Getter
|
||||||
public final class UserInfo {
|
public final class UserInfo {
|
||||||
private UserInfo() {
|
private UserInfo() {
|
||||||
}
|
}
|
||||||
@ -77,130 +79,6 @@ public final class UserInfo {
|
|||||||
@JSONField(name = "UserName")
|
@JSONField(name = "UserName")
|
||||||
private String userName;
|
private String userName;
|
||||||
|
|
||||||
public Long getUin() {
|
|
||||||
return uin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNickName() {
|
|
||||||
return nickName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getHeadImgUrl() {
|
|
||||||
return headImgUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getContactFlag() {
|
|
||||||
return contactFlag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getMemberCount() {
|
|
||||||
return memberCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<UserInfo> getMemberList() {
|
|
||||||
return memberList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRemarkName() {
|
|
||||||
return remarkName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getHideInputBarFlag() {
|
|
||||||
return hideInputBarFlag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getSex() {
|
|
||||||
return sex;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSignature() {
|
|
||||||
return signature;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getVerifyFlag() {
|
|
||||||
return verifyFlag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getOwnerUin() {
|
|
||||||
return ownerUin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPYInitial() {
|
|
||||||
return pyInitial;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPYQuanPin() {
|
|
||||||
return pyQuanPin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRemarkPYInitial() {
|
|
||||||
return remarkPYInitial;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRemarkPYQuanPin() {
|
|
||||||
return remarkPYQuanPin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getStarFriend() {
|
|
||||||
return starFriend;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getAppAccountFlag() {
|
|
||||||
return appAccountFlag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getStatues() {
|
|
||||||
return statues;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getAttrStatus() {
|
|
||||||
return attrStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getProvince() {
|
|
||||||
return province;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCity() {
|
|
||||||
return city;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAlias() {
|
|
||||||
return alias;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getSnsFlag() {
|
|
||||||
return snsFlag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getUniFriend() {
|
|
||||||
return uniFriend;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDisplayName() {
|
|
||||||
return displayName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getChatRoomId() {
|
|
||||||
return chatRoomId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getKeyWord() {
|
|
||||||
return keyWord;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEncryChatRoomId() {
|
|
||||||
return encryChatRoomId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getIsOwner() {
|
|
||||||
return isOwner;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUserName() {
|
|
||||||
return userName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static UserInfo valueOf(JSONObject info) {
|
public static UserInfo valueOf(JSONObject info) {
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
package com.hotlcc.wechat4j.model;
|
package com.hotlcc.wechat4j.model;
|
||||||
|
|
||||||
import com.alibaba.fastjson.annotation.JSONField;
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 要发送的消息
|
* 要发送的消息
|
||||||
*/
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
public class WxMessage {
|
public class WxMessage {
|
||||||
@JSONField(name = "ClientMsgId")
|
@JSONField(name = "ClientMsgId")
|
||||||
private String clientMsgId;
|
private String clientMsgId;
|
||||||
@ -18,52 +22,4 @@ public class WxMessage {
|
|||||||
private String toUserName;
|
private String toUserName;
|
||||||
@JSONField(name = "Type")
|
@JSONField(name = "Type")
|
||||||
private Integer type;
|
private Integer type;
|
||||||
|
|
||||||
public String getClientMsgId() {
|
|
||||||
return clientMsgId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setClientMsgId(String clientMsgId) {
|
|
||||||
this.clientMsgId = clientMsgId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getContent() {
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setContent(String content) {
|
|
||||||
this.content = content;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFromUserName() {
|
|
||||||
return fromUserName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFromUserName(String fromUserName) {
|
|
||||||
this.fromUserName = fromUserName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLocalID() {
|
|
||||||
return localID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLocalID(String localID) {
|
|
||||||
this.localID = localID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getToUserName() {
|
|
||||||
return toUserName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setToUserName(String toUserName) {
|
|
||||||
this.toUserName = toUserName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setType(Integer type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,8 @@ public final class PropertiesUtil {
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
loadProperties(new String[]{
|
loadProperties(new String[]{
|
||||||
"config/app.properties",
|
"META-INF/wechat4j/app.properties",
|
||||||
"config/webwx-url.properties"
|
"META-INF/wechat4j/webwx-url.properties"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import com.hotlcc.wechat4j.api.WebWeixinApi;
|
|||||||
import com.hotlcc.wechat4j.handler.ReceivedMsgHandler;
|
import com.hotlcc.wechat4j.handler.ReceivedMsgHandler;
|
||||||
import com.hotlcc.wechat4j.model.ReceivedMsg;
|
import com.hotlcc.wechat4j.model.ReceivedMsg;
|
||||||
import com.hotlcc.wechat4j.model.UserInfo;
|
import com.hotlcc.wechat4j.model.UserInfo;
|
||||||
|
import com.sun.scenario.effect.GaussianShadow;
|
||||||
|
|
||||||
public class TestClass2 {
|
public class TestClass2 {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
@ -22,5 +23,9 @@ public class TestClass2 {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
wechat.autoLogin();
|
wechat.autoLogin();
|
||||||
|
UserInfo userInfo = wechat.getContactByNickName(false, "Allen");
|
||||||
|
System.out.println(JSONObject.toJSONString(userInfo));
|
||||||
|
wechat.sendText("aaa", userInfo.getUserName());
|
||||||
|
wechat.logout();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user