{
"data": {
"phrase9": {
"value": "订单审核"
},
"character_string2": {
"value": "59240526999001703"
},
"thing8": {
"value": "测试景区"
},
"time5": {
"value": "2024-05-29"
}
},
"templateId": "RUvEZ6TN0QQjaoIkwi_ICnP58_n1Vr7XRQWBZQYMKhA",
"toUser": "o0phUw-3rgTqWw7hth5ahyTWFj3A",
"url": ""
}
WeiXinResponse result = restTemplate.postForObject(String.format(PUSH_MESSAGE_URL, access_token),
weChatTemplate.getData(), WeiXinResponse.class);
WeiXinResponse(errcode=47001, errmsg=data format error rid: 66569ae3-6fe89688-274b3e3b, msgid=null)
weChatTemplate: WeChatTemplate(touser=o0phUw-3rgTqWw7hth5ahyTWFj3A, template_id=RUvEZ6TN0QQjaoIkwi_ICnP58_n1Vr7XRQWBZQYMKhA, url=null, miniprogram=null, data={phrase9={value=订单审核}, character_string2={value=59240526999001703}, thing8={value=测试景区}, time5={value=2024-05-29}})
2024-05-29 14:47:45.986 [http-nio-8082-exec-3] INFO c.e.cloud.service.generator.impl.SmsServiceImpl:313 - url:https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=80_MvwE5V1xEtxA7vvTcptxI6wQ846LJ4N8pnbxvOX0yIrSNPKEYgrq4OdhkVDL45q_yDnFqqGQRl3bE1EcXUqewNohdAQqAO8-OJbGgHvXT3MG_RHZ36cEVQisONMJTLiAGAFPH
WeiXinResponse result = restTemplate.postForObject(String.format(PUSH_MESSAGE_URL, access_token), JSON.toJSON(weChatTemplate), WeiXinResponse.class); log.info(result.toString()); if (result.getErrmsg().equals("ok")) { log.info("PMS景区【" + poi.getName() + "】订单【" + orderInfo.getOrderCode() + "】已通知"); } if (result.getErrmsg() == null && !result.getErrmsg().equals("ok")) { log.info("出异常了,发送微信通知是吧"); //return Result.failure(ResultCode.SEND_MESSAGE_FAIL); }
为啥不看文档,哪来的toUser,templateId也不对,不是驼峰
2024-05-29 14:47:45.986 [http-nio-8082-exec-3] INFO c.e.cloud.service.generator.impl.SmsServiceImpl:313 - url:https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=80_MvwE5V1xEtxA7vvTcptxI6wQ846LJ4N8pnbxvOX0yIrSNPKEYgrq4OdhkVDL45q_yDnFqqGQRl3bE1EcXUqewNohdAQqAO8-OJbGgHvXT3MG_RHZ36cEVQisONMJTLiAGAFPH
WeiXinResponse result = restTemplate.postForObject(String.format(PUSH_MESSAGE_URL, access_token),
JSON.toJSON(weChatTemplate), WeiXinResponse.class);
log.info(result.toString());
if (result.getErrmsg().equals("ok")) {
log.info("PMS景区【" + poi.getName() + "】订单【" + orderInfo.getOrderCode() + "】已通知");
}
if (result.getErrmsg() == null && !result.getErrmsg().equals("ok")) {
log.info("出异常了,发送微信通知是吧");
//return Result.failure(ResultCode.SEND_MESSAGE_FAIL);
}
这个没有值就不要传递这个参数
{
"data": {
"character_string2": {
"value": "59240526999001703"
},
"thing1": {
"value": "订单审核"
}
},
"template_id": "T2EtukxgZAdvwEJ-VxdcGl_hJ89IMP5NNyyu5NHF2AM",
"touser": "o0phUw-3rgTqWw7hth5ahyTWFj3A"
}