微信小程序消息推送服务器接口返回数据问题

chunmancang8234 2018-01-11 01:15:15

tomcat运行日志

这是方法
```
/**
* 验证微信消息服务器
* @param request
* @param model
* @return
*/
@RequestMapping(value="/getToken")
public @ResponseBody
String getToken(HttpServletRequest request, Model model) {
String property = null;
try {
Properties properties = PropertiesLoaderUtils.loadAllProperties("weixin.properties");
property = properties.getProperty("xiaochengxu.token");
System.out.println(property);
} catch (IOException e) {
e.printStackTrace();
}
String signature = request.getParameter("signature");
System.out.println("signature:------------------"+signature);
String timestamp = request.getParameter("timestamp");
System.out.println("timestamp:------------------"+timestamp);
String nonce = request.getParameter("nonce");
System.out.println("nonce:------------------"+nonce);
String echostr = request.getParameter("echostr");
System.out.println("echostr:------------------"+echostr);
Map<String, String> map=new HashMap<>();
map.put("timestamp", timestamp);
map.put("nonce", nonce);
map.put("token", property);
String sha1 = CheckWxServer.formatUrlMap(map, true, false);//加密后的字符串
System.out.println("sha1:------------------"+sha1);
sha1=CheckWxServer.getSha1(sha1);
System.out.println("sha1:------------------"+sha1);
if(StringUtils.isNotBlank(signature)) {
if(signature.equals(sha1)) {
System.out.println("true:------------------"+sha1);
return echostr;//匹配成功,原样返回 echstr
}else {
System.out.println("false:------------------"+"Unsuccessful match");
return echostr;
}
}
System.out.println("false:------------------"+"Wrong Pram");
return echostr;
}
```
执行的这个

但还是校验失败

是我前面的逻辑错了,还是返回的格式问题,有没有用过消息推送的大神知道?
...全文
829 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
jrd7777 2018-01-11
  • 打赏
  • 举报
回复

把Return echostr 换成这个试试,微信签名好像不要引号

3,143

社区成员

发帖
与我相关
我的任务
社区描述
微信开发即微信公众平台开发,将企业信息、服务、活动等内容通过微信网页的方式进行表现,通过二次开发可以将公众账号由一个媒体型营销工具转化成提供服务的产品。
社区管理员
  • 微信开发
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧