如果公众号处于开发模式,普通微信用户向公众号发消息时,微信服务器会先将消息POST到开发者填写的url上,无法直接推送给微信自带的客服功能。如果需要把用户推送的普通消息推送到客服功能中,就需要进行代码修改。
代码:
public void customer(HttpServletResponse response) {
String msgType = "获取推送消息中的MsgType数据";
/**
* 判断微信推送的消息中的MsgType是否是event类型
* 不是event类型的,我们进行转发,因为只需要针对微信用户发来的消息才进行转发,而对于其他任何事件(比如菜单点击、地理位置上报等)都不应该转接,否则客服在客服系统上就会看到一些无意义的消息了。
* fromUsername 为推送消息的fromUsername
* toUsername 为推送消息的toUsername
*/
String time = System.currentTimeMillis()+"";
if (!"event".equalsIgnoreCase(msgType)) {
String textTpl=customerText(fromUsername, toUsername, time);
send(textTpl, response);
}
}
/**
* 封装发送xml
* @param fromUsername
* @param toUsername
* @param time
<