@Test public void testSetUserStorage() throws WxErrorException { this.wxService.getUserService().setUserStorage(ImmutableMap.of("1","2"), "r7BXXKkLb8qrSNn05n0qiA",((TestConfig)this.wxService.getWxMaConfig()).getOpenid()); }
@Override public void setUserStorage(Map<String, String> kvMap, String sessionKey, String openid) throws WxErrorException { final WxMaConfig config = this.service.getWxMaConfig(); JsonObject param = new JsonObject(); JsonArray array = new JsonArray(); for (Map.Entry<String, String> e : kvMap.entrySet()) { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("key", e.getKey()); jsonObject.addProperty("value", e.getValue()); array.add(jsonObject); } param.add("kv_list", array); String params = param.toString(); String signature = SignUtils.createHmacSha256Sign(params, sessionKey); String url = String.format("https: "?appid=%s&signature=%s&openid=%s&sig_method=%s", config.getAppid(), signature, openid, "hmac_sha256"); String result = this.service.post(url, params); WxError error = WxError.fromJson(result); if (error.getErrorCode() != 0) { throw new WxErrorException(error); } }
WxMaUserServiceImpl implements WxMaUserService { @Override public void setUserStorage(Map<String, String> kvMap, String sessionKey, String openid) throws WxErrorException { final WxMaConfig config = this.service.getWxMaConfig(); JsonObject param = new JsonObject(); JsonArray array = new JsonArray(); for (Map.Entry<String, String> e : kvMap.entrySet()) { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("key", e.getKey()); jsonObject.addProperty("value", e.getValue()); array.add(jsonObject); } param.add("kv_list", array); String params = param.toString(); String signature = SignUtils.createHmacSha256Sign(params, sessionKey); String url = String.format("https: "?appid=%s&signature=%s&openid=%s&sig_method=%s", config.getAppid(), signature, openid, "hmac_sha256"); String result = this.service.post(url, params); WxError error = WxError.fromJson(result); if (error.getErrorCode() != 0) { throw new WxErrorException(error); } } }
WxMaUserServiceImpl implements WxMaUserService { @Override public void setUserStorage(Map<String, String> kvMap, String sessionKey, String openid) throws WxErrorException { final WxMaConfig config = this.service.getWxMaConfig(); JsonObject param = new JsonObject(); JsonArray array = new JsonArray(); for (Map.Entry<String, String> e : kvMap.entrySet()) { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("key", e.getKey()); jsonObject.addProperty("value", e.getValue()); array.add(jsonObject); } param.add("kv_list", array); String params = param.toString(); String signature = SignUtils.createHmacSha256Sign(params, sessionKey); String url = String.format("https: "?appid=%s&signature=%s&openid=%s&sig_method=%s", config.getAppid(), signature, openid, "hmac_sha256"); String result = this.service.post(url, params); WxError error = WxError.fromJson(result); if (error.getErrorCode() != 0) { throw new WxErrorException(error); } } WxMaUserServiceImpl(WxMaService service); }
WxMaUserServiceImpl implements WxMaUserService { @Override public void setUserStorage(Map<String, String> kvMap, String sessionKey, String openid) throws WxErrorException { final WxMaConfig config = this.service.getWxMaConfig(); JsonObject param = new JsonObject(); JsonArray array = new JsonArray(); for (Map.Entry<String, String> e : kvMap.entrySet()) { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("key", e.getKey()); jsonObject.addProperty("value", e.getValue()); array.add(jsonObject); } param.add("kv_list", array); String params = param.toString(); String signature = SignUtils.createHmacSha256Sign(params, sessionKey); String url = String.format("https: "?appid=%s&signature=%s&openid=%s&sig_method=%s", config.getAppid(), signature, openid, "hmac_sha256"); String result = this.service.post(url, params); WxError error = WxError.fromJson(result); if (error.getErrorCode() != 0) { throw new WxErrorException(error); } } WxMaUserServiceImpl(WxMaService service); @Override WxMaJscode2SessionResult getSessionInfo(String jsCode); @Override WxMaUserInfo getUserInfo(String sessionKey, String encryptedData, String ivStr); @Override void setUserStorage(Map<String, String> kvMap, String sessionKey, String openid); @Override WxMaPhoneNumberInfo getPhoneNoInfo(String sessionKey, String encryptedData, String ivStr); @Override boolean checkUserInfo(String sessionKey, String rawData, String signature); }
WxMaUserServiceImpl implements WxMaUserService { @Override public void setUserStorage(Map<String, String> kvMap, String sessionKey, String openid) throws WxErrorException { final WxMaConfig config = this.service.getWxMaConfig(); JsonObject param = new JsonObject(); JsonArray array = new JsonArray(); for (Map.Entry<String, String> e : kvMap.entrySet()) { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("key", e.getKey()); jsonObject.addProperty("value", e.getValue()); array.add(jsonObject); } param.add("kv_list", array); String params = param.toString(); String signature = SignUtils.createHmacSha256Sign(params, sessionKey); String url = String.format("https: "?appid=%s&signature=%s&openid=%s&sig_method=%s", config.getAppid(), signature, openid, "hmac_sha256"); String result = this.service.post(url, params); WxError error = WxError.fromJson(result); if (error.getErrorCode() != 0) { throw new WxErrorException(error); } } WxMaUserServiceImpl(WxMaService service); @Override WxMaJscode2SessionResult getSessionInfo(String jsCode); @Override WxMaUserInfo getUserInfo(String sessionKey, String encryptedData, String ivStr); @Override void setUserStorage(Map<String, String> kvMap, String sessionKey, String openid); @Override WxMaPhoneNumberInfo getPhoneNoInfo(String sessionKey, String encryptedData, String ivStr); @Override boolean checkUserInfo(String sessionKey, String rawData, String signature);  }