我的报错
https buffer:{“errcode”:40001,“errmsg”:“invalid credential, access_token is invalid or not latest, hints: [ req_id: EzyZwA09845293 ]”}
2019-01-08 14:29:44.669 [http-nio-80-exec-6] DEBUG com.luyu.iot.util.WechatUtil - user info :{“errcode”:40001,“errmsg”:“invalid credential, access_token is invalid or not latest, hints: [ req_id: EzyZwA09845293 ]”}
看到您之前回答别人的是controller的问题但是我发现我的微信接口url只能配置类似的http://xxxx.xxx.xxx.x/iot/wechat/ 也就是wechat后面多一个“/”才能配置成功
这是我的controller
@Controller
//一会在设置的URL里面就设置上这个路由
@RequestMapping(value = “wechat”, method = { RequestMethod.GET, RequestMethod.POST })
public class WechatController {
private static Logger log = LoggerFactory.getLogger(WechatController.class);
@RequestMapping(method = { RequestMethod.GET })
public void doGet(HttpServletRequest request, HttpServletResponse response) {
log.debug("weixin get...");
// 微信加密签名,signature结合了开发者填写的token参数和请求中的timestamp参数、nonce参数。
String signature = request.getParameter("signature");
// 时间戳
String timestamp = request.getParameter("timestamp");
// 随机数
String nonce = request.getParameter("nonce");
// 随机字符串
String echostr = request.getParameter("echostr");
// 通过检验signature对请求进行校验,若校验成功则原样返回echostr,表示接入成功,否则接入失败
PrintWriter out = null;
try {
out = response.getWriter();
if (SignUtil.checkSignature(signature, timestamp, nonce)) {
log.debug("weixin get success....");
out.print(echostr);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (out != null)
out.close();
}
}
}
SSM商铺V1.0,解决毕设痛点;SpringBoot商铺V2.0,满足工作刚需
了解课程