mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-12-21 19:10:01 +08:00
issue #4 获取关注者列表
This commit is contained in:
@@ -7,6 +7,7 @@ import chanjarster.weixin.bean.WxMassNews;
|
||||
import chanjarster.weixin.bean.WxMassOpenIdsMessage;
|
||||
import chanjarster.weixin.bean.WxMenu;
|
||||
import chanjarster.weixin.bean.result.WxUser;
|
||||
import chanjarster.weixin.bean.result.WxUserList;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
@@ -24,6 +25,7 @@ public class WxGsonBuilder {
|
||||
INSTANCE.registerTypeAdapter(WxMassOpenIdsMessage.class, new WxMassOpenIdsMessageGsonAdapter());
|
||||
INSTANCE.registerTypeAdapter(WxGroup.class, new WxGroupGsonAdapter());
|
||||
INSTANCE.registerTypeAdapter(WxUser.class, new WxUserGsonAdapter());
|
||||
INSTANCE.registerTypeAdapter(WxUserList.class, new WxUserListGsonAdapter());
|
||||
}
|
||||
|
||||
public static Gson create() {
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* KINGSTAR MEDIA SOLUTIONS Co.,LTD. Copyright c 2005-2013. All rights reserved.
|
||||
*
|
||||
* This source code is the property of KINGSTAR MEDIA SOLUTIONS LTD. It is intended
|
||||
* only for the use of KINGSTAR MEDIA application development. Reengineering, reproduction
|
||||
* arose from modification of the original source, or other redistribution of this source
|
||||
* is not permitted without written permission of the KINGSTAR MEDIA SOLUTIONS LTD.
|
||||
*/
|
||||
package chanjarster.weixin.util.json;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import chanjarster.weixin.bean.result.WxUserList;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author qianjia
|
||||
*
|
||||
*/
|
||||
public class WxUserListGsonAdapter implements JsonDeserializer<WxUserList> {
|
||||
|
||||
public WxUserList deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
JsonObject o = json.getAsJsonObject();
|
||||
WxUserList wxUserList = new WxUserList();
|
||||
wxUserList.setTotal(GsonHelper.getInteger(o, "total"));
|
||||
wxUserList.setCount(GsonHelper.getInteger(o, "count"));
|
||||
wxUserList.setNext_openid(GsonHelper.getString(o, "next_openid"));
|
||||
JsonArray data = o.get("data").getAsJsonObject().get("openid").getAsJsonArray();
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
wxUserList.getOpenids().add(GsonHelper.getAsString(data.get(i)));
|
||||
}
|
||||
return wxUserList;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user