String accessToken = getAccessToken(requestDTO.getAppId(), requestDTO.getSecret());
String url = "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=" + accessToken;
Map<String, Object> param = new HashMap<String, Object>();
param.put("touser", requestDTO.getOpenId());
param.put("template_id", requestDTO.getTemplateId());
param.put("page", "pages/ddctime/ddctime");
param.put("form_id", requestDTO.getFormId());
//TODO
logger.info("weixin push request fomrnId is {}", requestDTO.getFormId());
Map<String, Object> data = new HashMap<String, Object>();
Map<String, Object> keyword1 = new HashMap<String, Object>();
keyword1.put("value", requestDTO.getKeyword1());
data.put("keyword1", keyword1);
Map<String, Object> keyword2 = new HashMap<String, Object>();
keyword2.put("value", requestDTO.getKeyword2());
data.put("keyword2", keyword2);
Map<String, Object> keyword3 = new HashMap<String, Object>();
keyword3.put("value", requestDTO.getKeyword3());
data.put("keyword3", keyword3);
Map<String, Object> keyword4 = new HashMap<String, Object>();
keyword4.put("value", requestDTO.getKeyword4());
data.put("keyword4", keyword4);
param.put("data", data);
logger.info(JsonUtil.objectToJSON(param));
//param.put("mp_template_msg", value);
HttpHeaders headers = new HttpHeaders();
MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
headers.setContentType(type);
headers.add("Accept", MediaType.APPLICATION_JSON.toString());
String params = JsonUtil.objectToJSON(param);
logger.info("weixin push param is {}", params);
HttpEntity<String> formEntity = new HttpEntity<String>(params, headers);
Map<String, Object> resultMap = restTemplate.postForObject(url, formEntity, Map.class);
logger.info(JsonUtil.objectToJSON(resultMap));
logger.info("weixin push result is {}", JsonUtil.objectToJSON(resultMap));
return JsonUtil.objectToJSON(resultMap);
每次都是报41028 form_id不正确,求救
检查你的formid,具体是怎么获取的,格式是什么样的,日志记录输出的是什么?