@Test public void testToOpenId(){ Map<String, String> response = QyOAuth2s.defaultOAuth2s().toOpenId(45, "borball"); System.out.print("woden|"); System.out.print(response.get("appid")); System.out.print("|"); System.out.println(response.get("openid")); }
public Map<String, String> toOpenId(int agentId, String userId) { String url = WxEndpoint.get("url.oauth.uid2openid"); Map<String, Object> request = new HashMap<>(); request.put("userid", userId); request.put("agentid", agentId); logger.debug("agent[{}], userId[{}] to openId", agentId, userId); String response = wxClient.post(url, JsonMapper.defaultMapper().toJson(request)); Map<String, Object> result = JsonMapper.defaultMapper().json2Map(response); if (result.containsKey("errcode") && (Integer) result.get("errcode") == 0) { Map<String, String> map = new HashMap<>(); map.put("openid", result.get("openid").toString()); map.put("appid", result.get("appid").toString()); return map; } else { throw new WxRuntimeException(999, "user id to open id failed."); } }
QyOAuth2s { public Map<String, String> toOpenId(int agentId, String userId) { String url = WxEndpoint.get("url.oauth.uid2openid"); Map<String, Object> request = new HashMap<>(); request.put("userid", userId); request.put("agentid", agentId); logger.debug("agent[{}], userId[{}] to openId", agentId, userId); String response = wxClient.post(url, JsonMapper.defaultMapper().toJson(request)); Map<String, Object> result = JsonMapper.defaultMapper().json2Map(response); if (result.containsKey("errcode") && (Integer) result.get("errcode") == 0) { Map<String, String> map = new HashMap<>(); map.put("openid", result.get("openid").toString()); map.put("appid", result.get("appid").toString()); return map; } else { throw new WxRuntimeException(999, "user id to open id failed."); } } }
QyOAuth2s { public Map<String, String> toOpenId(int agentId, String userId) { String url = WxEndpoint.get("url.oauth.uid2openid"); Map<String, Object> request = new HashMap<>(); request.put("userid", userId); request.put("agentid", agentId); logger.debug("agent[{}], userId[{}] to openId", agentId, userId); String response = wxClient.post(url, JsonMapper.defaultMapper().toJson(request)); Map<String, Object> result = JsonMapper.defaultMapper().json2Map(response); if (result.containsKey("errcode") && (Integer) result.get("errcode") == 0) { Map<String, String> map = new HashMap<>(); map.put("openid", result.get("openid").toString()); map.put("appid", result.get("appid").toString()); return map; } else { throw new WxRuntimeException(999, "user id to open id failed."); } }  }
QyOAuth2s { public Map<String, String> toOpenId(int agentId, String userId) { String url = WxEndpoint.get("url.oauth.uid2openid"); Map<String, Object> request = new HashMap<>(); request.put("userid", userId); request.put("agentid", agentId); logger.debug("agent[{}], userId[{}] to openId", agentId, userId); String response = wxClient.post(url, JsonMapper.defaultMapper().toJson(request)); Map<String, Object> result = JsonMapper.defaultMapper().json2Map(response); if (result.containsKey("errcode") && (Integer) result.get("errcode") == 0) { Map<String, String> map = new HashMap<>(); map.put("openid", result.get("openid").toString()); map.put("appid", result.get("appid").toString()); return map; } else { throw new WxRuntimeException(999, "user id to open id failed."); } }  static QyOAuth2s defaultOAuth2s(); static QyOAuth2s with(CorpSetting corpSetting); void setWxClient(WxClient wxClient); String authenticationUrl(String redirect, String state); QyUser userInfo(String code); Map<String, String> toOpenId(int agentId, String userId); String toOpenId(String userId); String toUserId(String openId); }
QyOAuth2s { public Map<String, String> toOpenId(int agentId, String userId) { String url = WxEndpoint.get("url.oauth.uid2openid"); Map<String, Object> request = new HashMap<>(); request.put("userid", userId); request.put("agentid", agentId); logger.debug("agent[{}], userId[{}] to openId", agentId, userId); String response = wxClient.post(url, JsonMapper.defaultMapper().toJson(request)); Map<String, Object> result = JsonMapper.defaultMapper().json2Map(response); if (result.containsKey("errcode") && (Integer) result.get("errcode") == 0) { Map<String, String> map = new HashMap<>(); map.put("openid", result.get("openid").toString()); map.put("appid", result.get("appid").toString()); return map; } else { throw new WxRuntimeException(999, "user id to open id failed."); } }  static QyOAuth2s defaultOAuth2s(); static QyOAuth2s with(CorpSetting corpSetting); void setWxClient(WxClient wxClient); String authenticationUrl(String redirect, String state); QyUser userInfo(String code); Map<String, String> toOpenId(int agentId, String userId); String toOpenId(String userId); String toUserId(String openId);  }