@Override public long getLongValue(String key) { return jsonObject.getLongValue(key); }
@Override public long getLongValue(String key) { return jsonObject.getLongValue(key); }
public ComponentInfo(JSONObject json) { this.name = json.getString(NAME); this.id = json.getString(ID); this.type = json.getString(TYPE); this.version = json.getLongValue(VERSION); this.url = json.getString(URL); }
private void getUinAndPsessionid() { LOGGER.debug("开始获取uin和psessionid"); JSONObject r = new JSONObject(); r.put("ptwebqq", ptwebqq); r.put("clientid", Client_ID); r.put("psessionid", ""); r.put("status", "online"); Response<String> response = post(ApiURL.GET_UIN_AND_PSESSIONID, r); JSONObject result = getJsonObjectResult(response); this.psessionid = result.getString("psessionid"); this.uin = result.getLongValue("uin"); }
public GroupMessage(JSONObject json) { JSONArray cont = json.getJSONArray("content"); this.font = cont.getJSONArray(0).getObject(1, Font.class); final int size = cont.size(); final StringBuilder contentBuilder = new StringBuilder(); for (int i = 1; i < size; i++) { contentBuilder.append(cont.getString(i)); } this.content = contentBuilder.toString(); this.time = json.getLongValue("time"); this.groupId = json.getLongValue("group_code"); this.userId = json.getLongValue("send_uin"); }
/** * 获得qq号 * * @param friendId 用户id * @return */ public long getQQById(long friendId) { LOGGER.debug("开始获取QQ号"); Response<String> response = get(ApiURL.GET_QQ_BY_ID, friendId, vfwebqq); return getJsonObjectResult(response).getLongValue("account"); }
public DiscussMessage(JSONObject json) { JSONArray content = json.getJSONArray("content"); this.font = content.getJSONArray(0).getObject(1, Font.class); this.content = content.getString(1); if (content.size() > 2) this.content += content.getString(3); this.time = json.getLongValue("time"); this.discussId = json.getLongValue("did"); this.userId = json.getLongValue("send_uin"); }
public Message(JSONObject json) { JSONArray cont = json.getJSONArray("content"); this.font = cont.getJSONArray(0).getObject(1, Font.class); final int size = cont.size(); final StringBuilder contentBuilder = new StringBuilder(); for (int i = 1; i < size; i++) { contentBuilder.append(cont.getString(i)); } this.content = contentBuilder.toString(); this.time = json.getLongValue("time"); this.userId = json.getLongValue("from_uin"); }
source.ip = params.getJSONObject("source").getString("ip"); source.state = RaftPeer.State.valueOf(params.getJSONObject("source").getString("state")); source.term.set(params.getJSONObject("source").getLongValue("term")); source.heartbeatDueMs = params.getJSONObject("source").getLongValue("heartbeatDueMs"); source.leaderDueMs = params.getJSONObject("source").getLongValue("leaderDueMs"); source.voteFor = params.getJSONObject("source").getString("voteFor");
remote.ip = beat.getJSONObject("peer").getString("ip"); remote.state = RaftPeer.State.valueOf(beat.getJSONObject("peer").getString("state")); remote.term.set(beat.getJSONObject("peer").getLongValue("term")); remote.heartbeatDueMs = beat.getJSONObject("peer").getLongValue("heartbeatDueMs"); remote.leaderDueMs = beat.getJSONObject("peer").getLongValue("leaderDueMs"); remote.voteFor = beat.getJSONObject("peer").getString("voteFor");
/** * 获得好友列表(包含分组信息) * * @return */ public List<Category> getFriendListWithCategory() { LOGGER.debug("开始获取好友列表"); JSONObject r = new JSONObject(); r.put("vfwebqq", vfwebqq); r.put("hash", hash()); Response<String> response = post(ApiURL.GET_FRIEND_LIST, r); JSONObject result = getJsonObjectResult(response); //获得好友信息 Map<Long, Friend> friendMap = parseFriendMap(result); //获得分组 JSONArray categories = result.getJSONArray("categories"); Map<Integer, Category> categoryMap = new HashMap<>(); categoryMap.put(0, Category.defaultCategory()); for (int i = 0; categories != null && i < categories.size(); i++) { Category category = categories.getObject(i, Category.class); categoryMap.put(category.getIndex(), category); } JSONArray friends = result.getJSONArray("friends"); for (int i = 0; friends != null && i < friends.size(); i++) { JSONObject item = friends.getJSONObject(i); Friend friend = friendMap.get(item.getLongValue("uin")); categoryMap.get(item.getIntValue("categories")).addFriend(friend); } return new ArrayList<>(categoryMap.values()); }
private static Map<Long, Friend> parseFriendMap(JSONObject result) { Map<Long, Friend> friendMap = new HashMap<>(); JSONArray info = result.getJSONArray("info"); for (int i = 0; info != null && i < info.size(); i++) { JSONObject item = info.getJSONObject(i); Friend friend = new Friend(); friend.setUserId(item.getLongValue("uin")); friend.setNickname(item.getString("nick")); friendMap.put(friend.getUserId(), friend); } JSONArray marknames = result.getJSONArray("marknames"); for (int i = 0; marknames != null && i < marknames.size(); i++) { JSONObject item = marknames.getJSONObject(i); friendMap.get(item.getLongValue("uin")).setMarkname(item.getString("markname")); } JSONArray vipinfo = result.getJSONArray("vipinfo"); for (int i = 0; vipinfo != null && i < vipinfo.size(); i++) { JSONObject item = vipinfo.getJSONObject(i); Friend friend = friendMap.get(item.getLongValue("u")); friend.setVip(item.getIntValue("is_vip") == 1); friend.setVipLevel(item.getIntValue("vip_level")); } return friendMap; }
/** * 获得讨论组的详细信息 * * @param discussId 讨论组id * @return */ public DiscussInfo getDiscussInfo(long discussId) { LOGGER.debug("开始获取讨论组资料"); Response<String> response = get(ApiURL.GET_DISCUSS_INFO, discussId, vfwebqq, psessionid); JSONObject result = getJsonObjectResult(response); DiscussInfo discussInfo = result.getObject("info", DiscussInfo.class); //获得讨论组成员信息 Map<Long, DiscussUser> discussUserMap = new HashMap<>(); JSONArray minfo = result.getJSONArray("mem_info"); for (int i = 0; minfo != null && i < minfo.size(); i++) { DiscussUser discussUser = minfo.getObject(i, DiscussUser.class); discussUserMap.put(discussUser.getUin(), discussUser); discussInfo.addUser(discussUser); } JSONArray stats = result.getJSONArray("mem_status"); for (int i = 0; stats != null && i < stats.size(); i++) { JSONObject item = stats.getJSONObject(i); DiscussUser discussUser = discussUserMap.get(item.getLongValue("uin")); discussUser.setClientType(item.getIntValue("client_type")); discussUser.setStatus(item.getString("status")); } return discussInfo; }
for (int i = 0; stats != null && i < stats.size(); i++) { JSONObject item = stats.getJSONObject(i); GroupUser groupUser = groupUserMap.get(item.getLongValue("uin")); groupUser.setClientType(item.getIntValue("client_type")); groupUser.setStatus(item.getIntValue("stat")); for (int i = 0; cards != null && i < cards.size(); i++) { JSONObject item = cards.getJSONObject(i); groupUserMap.get(item.getLongValue("muin")).setCard(item.getString("card")); GroupUser groupUser = groupUserMap.get(item.getLongValue("u")); groupUser.setVip(item.getIntValue("is_vip") == 1); groupUser.setVipLevel(item.getIntValue("vip_level"));
long exceptId = real.getLongValue(KEY_ID); for (String u : uniques) { verifyRepeat(name, u, real.get(u), exceptId, creator);
@Override public Token create() throws WeixinException { JSONObject obj = new JSONObject(); obj.put("corpid", corpid); obj.put("provider_secret", providersecret); WeixinResponse response = weixinExecutor.post( URLConsts.PROVIDER_TOKEN_URL, obj.toJSONString()); obj = response.getAsJson(); return new Token(obj.getString("provider_access_token"), obj.getLongValue("expires_in") * 1000l); } }
@Override public Token create() throws WeixinException { String tokenUrl = String.format(URLConsts.ASSESS_TOKEN_URL, appid, secret); WeixinResponse response = weixinExecutor.get(tokenUrl); JSONObject result = response.getAsJson(); return new Token(result.getString("access_token"), result.getLongValue("expires_in") * 1000l); } }
@Override public Token create() throws WeixinException { WeixinResponse response = weixinExecutor.post( String.format(URLConsts.COMPONENET_PRE_CODE_URL, componentTokenManager.getAccessToken()), String.format("{\"component_appid\":\"%s\"}", componentId)); JSONObject result = response.getAsJson(); return new Token(result.getString("pre_auth_code"), result.getLongValue("expires_in") * 1000l); }
@Override public Token create() throws WeixinException { WeixinResponse response = weixinExecutor.post( String.format(URLConsts.SUITE_PRE_CODE_URL, suiteTokenManager.getAccessToken()), String.format("{\"suite_id\":\"%s\"}", suiteId)); JSONObject result = response.getAsJson(); return new Token(result.getString("pre_auth_code"), result.getLongValue("expires_in") * 1000l); } }
@Override public Token create() throws WeixinException { JSONObject obj = new JSONObject(); obj.put("component_appid", ticketManager.getThirdId()); obj.put("component_appsecret", ticketManager.getThirdSecret()); obj.put("component_verify_ticket", ticketManager.getAccessTicket()); WeixinResponse response = weixinExecutor.post(URLConsts.COMPONENT_TOKEN_URL, obj.toJSONString()); obj = response.getAsJson(); return new Token(obj.getString("component_access_token"), obj.getLongValue("expires_in") * 1000l); } }