|
|
|
@ -55,32 +55,32 @@ public class WxMsgController { |
|
|
|
|
@Resource |
|
|
|
|
private HighMerchantStoreService merchantStoreService; |
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/verifyWxToken", method = RequestMethod.GET) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "验证servlet") |
|
|
|
|
public String verifyWxToken( |
|
|
|
|
@RequestParam(name = "signature", required = false) String signature, |
|
|
|
|
@RequestParam(name = "timestamp", required = false) String timestamp, |
|
|
|
|
@RequestParam(name = "nonce", required = false) String nonce, |
|
|
|
|
@RequestParam(name = "echostr", required = false) String echostr |
|
|
|
|
) { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
String signatureStr = WxUtils.getSHA1("RgAWdnR5oEOLBdyEjfr4" , timestamp , nonce); |
|
|
|
|
log.info("signatureStr!!!!!" + signatureStr); |
|
|
|
|
log.info("signature!!!!!" + signature); |
|
|
|
|
if (signature.equals(signatureStr)) { |
|
|
|
|
log.info("验证通过!!!!!"); |
|
|
|
|
return echostr; |
|
|
|
|
} |
|
|
|
|
log.info("验证失败!!!!!"); |
|
|
|
|
return null; |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
// @RequestMapping(value = "/verifyWxToken", method = RequestMethod.GET)
|
|
|
|
|
// @ResponseBody
|
|
|
|
|
// @ApiOperation(value = "验证servlet")
|
|
|
|
|
// public String verifyWxToken(
|
|
|
|
|
// @RequestParam(name = "signature", required = false) String signature,
|
|
|
|
|
// @RequestParam(name = "timestamp", required = false) String timestamp,
|
|
|
|
|
// @RequestParam(name = "nonce", required = false) String nonce,
|
|
|
|
|
// @RequestParam(name = "echostr", required = false) String echostr
|
|
|
|
|
// ) {
|
|
|
|
|
//
|
|
|
|
|
// try {
|
|
|
|
|
//
|
|
|
|
|
// String signatureStr = WxUtils.getSHA1("RgAWdnR5oEOLBdyEjfr4" , timestamp , nonce);
|
|
|
|
|
// log.info("signatureStr!!!!!" + signatureStr);
|
|
|
|
|
// log.info("signature!!!!!" + signature);
|
|
|
|
|
// if (signature.equals(signatureStr)) {
|
|
|
|
|
// log.info("验证通过!!!!!");
|
|
|
|
|
// return echostr;
|
|
|
|
|
// }
|
|
|
|
|
// log.info("验证失败!!!!!");
|
|
|
|
|
// return null;
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
// return null;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
@RequestMapping(value = "/verifyWxToken", method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "验证servlet") |
|
|
|
@ -251,4 +251,32 @@ public class WxMsgController { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/verifyWx", method = RequestMethod.GET) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "微信签名") |
|
|
|
|
public String verifyWx() { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
|
params.put("appid", SysConst.getSysConfig().getWxH5AppId()); |
|
|
|
|
params.put("secret", SysConst.getSysConfig().getWxH5AppSecret()); |
|
|
|
|
params.put("grant_type", "client_credential"); |
|
|
|
|
|
|
|
|
|
JSONObject accessTokenObject = HttpsUtils.doGet("https://api.weixin.qq.com/cgi-bin/token", params); |
|
|
|
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
map.put("noncestr","Wm3WZYTPz0wzccnW"); |
|
|
|
|
map.put("jsapi_ticket",accessTokenObject.getString("ticket")); |
|
|
|
|
map.put("timestamp","1414587457"); |
|
|
|
|
map.put("url","http://mp.weixin.qq.com?params=value"); |
|
|
|
|
|
|
|
|
|
return WxUtils.getSHA1(map); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|