小程序
小游戏
企业微信
微信支付
扫描小程序码分享
我的模板消息如下
在推送的时候,如果各项不包含中文内容,那么推送就是正常的。
正常情况下推送到“服务通知”里,如下图:
当模板消息输入汉字时,就会被推送到客服消息,并且推送内容也是异常的,如下图:
3 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
show me your code
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
//授权(必填) String grant_type = "client_credential"; //////////////// 1、向微信服务器 使用登录凭证 code 获取 session_key 和 openid //////////////// //请求参数 String params = "grant_type=" + grant_type + "&appid=" + wxspAppid + "&secret=" + wxspSecret; try { //1 获得token //发送请求 String sr = HttpRequest.sendGet("https://api.weixin.qq.com/cgi-bin/token", params); Map json = JsonMapper.getInstance().fromJson(sr, Map.class); //获取会话密钥(session_key) String access_token = json.get("access_token").toString(); //2发送模板消息 Map templateParams = new LinkedHashMap(); templateParams.put("touser", openid); templateParams.put("template_id", "cI_iWftkKinDcQFF82Q87ppTW6LpGFzYiMOwP6y1JJQ"); templateParams.put("page", "/pages/index/index"); templateParams.put("form_id", formid); Map keyword = new LinkedHashMap(); Map keyword1Vlue = new HashMap(); keyword1Vlue.put("value", nickname); keyword.put("keyword1", keyword1Vlue); Map keyword2Vlue = new HashMap(); keyword2Vlue.put("value", username); keyword.put("keyword2", keyword2Vlue); Map keyword3Vlue = new HashMap(); keyword3Vlue.put("value", phone); keyword.put("keyword3", keyword3Vlue); Map keyword4Vlue = new HashMap(); keyword4Vlue.put("value", content); keyword.put("keyword4", keyword4Vlue); Map keyword5Vlue = new HashMap(); keyword5Vlue.put("value", DateUtils.formatDateTime(new Date())); keyword.put("keyword5", keyword5Vlue); templateParams.put("data", keyword); String jsonString = JsonMapper.toJsonString(templateParams); String postRes = HttpRequest.sendPost("https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=" + access_token, jsonString);
map.put("status", 1); map.put("msg", postRes); } catch (Exception e) { e.printStackTrace(); map.put("status", 0); map.put("msg", "发送失败"); }
==========================================================
汉字发送JSON如下
{ "touser": "oQT364hJ017k4u4OK4eAFOUPXkCA", "template_id": "cI_iWftkKinDcQFF82Q87ppTW6LpGFzYiMOwP6y1JJQ", "page": "/pages/index/index", "form_id": "cf4c02b0dc73b14f829492b4049b12df", "data": { "keyword1": { "value": "东方" }, "keyword2": { "value": "我不知道" }, "keyword3": { "value": "13813972654" }, "keyword4": { "value": "咔咔咔好好打野野心勃勃谢娜经典款见面的机会" }, "keyword5": { "value": "2018-07-18 19:18:49" } } } 微信返回如下 {"errcode":0,"errmsg":"ok"}
===================================================
非汉字发送JSON如下
{ "touser": "oQT364hJ017k4u4OK4eAFOUPXkCA", "template_id": "cI_iWftkKinDcQFF82Q87ppTW6LpGFzYiMOwP6y1JJQ", "page": "/pages/index/index", "form_id": "d478dfd25b7da72a537987eaa8cfc737", "data": { "keyword1": { "value": "nick" }, "keyword2": { "value": "332" }, "keyword3": { "value": "13813976996" }, "keyword4": { "value": "3315549798455213464875422133346657572154587994646312755421" }, "keyword5": { "value": "2018-07-19 09:12:49" } } }
微信返回如下 {"errcode":0,"errmsg":"ok"}
是不是文字编码的问题,我们用utf8正常
微信返回码都是正常
我怀疑这是小程序的bug
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
show me your code
//授权(必填)
String grant_type = "client_credential";
//////////////// 1、向微信服务器 使用登录凭证 code 获取 session_key 和 openid ////////////////
//请求参数
String params = "grant_type=" + grant_type + "&appid=" + wxspAppid + "&secret=" + wxspSecret;
try {
//1 获得token
//发送请求
String sr = HttpRequest.sendGet("https://api.weixin.qq.com/cgi-bin/token", params);
Map json = JsonMapper.getInstance().fromJson(sr, Map.class);
//获取会话密钥(session_key)
String access_token = json.get("access_token").toString();
//2发送模板消息
Map templateParams = new LinkedHashMap();
templateParams.put("touser", openid);
templateParams.put("template_id", "cI_iWftkKinDcQFF82Q87ppTW6LpGFzYiMOwP6y1JJQ");
templateParams.put("page", "/pages/index/index");
templateParams.put("form_id", formid);
Map keyword = new LinkedHashMap();
Map keyword1Vlue = new HashMap();
keyword1Vlue.put("value", nickname);
keyword.put("keyword1", keyword1Vlue);
Map keyword2Vlue = new HashMap();
keyword2Vlue.put("value", username);
keyword.put("keyword2", keyword2Vlue);
Map keyword3Vlue = new HashMap();
keyword3Vlue.put("value", phone);
keyword.put("keyword3", keyword3Vlue);
Map keyword4Vlue = new HashMap();
keyword4Vlue.put("value", content);
keyword.put("keyword4", keyword4Vlue);
Map keyword5Vlue = new HashMap();
keyword5Vlue.put("value", DateUtils.formatDateTime(new Date()));
keyword.put("keyword5", keyword5Vlue);
templateParams.put("data", keyword);
String jsonString = JsonMapper.toJsonString(templateParams);
String postRes = HttpRequest.sendPost("https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=" + access_token, jsonString);
map.put("status", 1);
map.put("msg", postRes);
} catch (Exception e) {
e.printStackTrace();
map.put("status", 0);
map.put("msg", "发送失败");
}
==========================================================
汉字发送JSON如下
{
"touser": "oQT364hJ017k4u4OK4eAFOUPXkCA",
"template_id": "cI_iWftkKinDcQFF82Q87ppTW6LpGFzYiMOwP6y1JJQ",
"page": "/pages/index/index",
"form_id": "cf4c02b0dc73b14f829492b4049b12df",
"data": {
"keyword1": {
"value": "东方"
},
"keyword2": {
"value": "我不知道"
},
"keyword3": {
"value": "13813972654"
},
"keyword4": {
"value": "咔咔咔好好打野野心勃勃谢娜经典款见面的机会"
},
"keyword5": {
"value": "2018-07-18 19:18:49"
}
}
}
微信返回如下
{"errcode":0,"errmsg":"ok"}
===================================================
非汉字发送JSON如下
{
"touser": "oQT364hJ017k4u4OK4eAFOUPXkCA",
"template_id": "cI_iWftkKinDcQFF82Q87ppTW6LpGFzYiMOwP6y1JJQ",
"page": "/pages/index/index",
"form_id": "d478dfd25b7da72a537987eaa8cfc737",
"data": {
"keyword1": {
"value": "nick"
},
"keyword2": {
"value": "332"
},
"keyword3": {
"value": "13813976996"
},
"keyword4": {
"value": "3315549798455213464875422133346657572154587994646312755421"
},
"keyword5": {
"value": "2018-07-19 09:12:49"
}
}
}
微信返回如下
{"errcode":0,"errmsg":"ok"}
是不是文字编码的问题,我们用utf8正常
微信返回码都是正常
==========================================================
汉字发送JSON如下
{
"touser": "oQT364hJ017k4u4OK4eAFOUPXkCA",
"template_id": "cI_iWftkKinDcQFF82Q87ppTW6LpGFzYiMOwP6y1JJQ",
"page": "/pages/index/index",
"form_id": "cf4c02b0dc73b14f829492b4049b12df",
"data": {
"keyword1": {
"value": "东方"
},
"keyword2": {
"value": "我不知道"
},
"keyword3": {
"value": "13813972654"
},
"keyword4": {
"value": "咔咔咔好好打野野心勃勃谢娜经典款见面的机会"
},
"keyword5": {
"value": "2018-07-18 19:18:49"
}
}
}
微信返回如下
{"errcode":0,"errmsg":"ok"}
===================================================
非汉字发送JSON如下
{
"touser": "oQT364hJ017k4u4OK4eAFOUPXkCA",
"template_id": "cI_iWftkKinDcQFF82Q87ppTW6LpGFzYiMOwP6y1JJQ",
"page": "/pages/index/index",
"form_id": "d478dfd25b7da72a537987eaa8cfc737",
"data": {
"keyword1": {
"value": "nick"
},
"keyword2": {
"value": "332"
},
"keyword3": {
"value": "13813976996"
},
"keyword4": {
"value": "3315549798455213464875422133346657572154587994646312755421"
},
"keyword5": {
"value": "2018-07-19 09:12:49"
}
}
}
微信返回如下
{"errcode":0,"errmsg":"ok"}
我怀疑这是小程序的bug