@Value("${custom.wechat.appId}")
private String wechatAppId; //微信公众号appID
@Value("${custom.wechat.secret}")
private String wechatSecret; //微信公众号appsecret
@GetMapping(value = "/wechatAuthorization")
@ApiOperation(value = "微信验证")
public ResultVO wechatAuthorization(@RequestParam String wechatCode) {
try {
if (StringUtils.isEmpty(wechatCode)) {
return ResultVO.FAIL("请先获取微信授权!", null);
}
Map<String, String> param = new HashMap<>();
param.put("appid", wechatAppId);
param.put("secret", wechatSecret);
param.put("code", wechatCode);
param.put("grant_type", "authorization_code");
RestTemplate restTemplate = new RestTemplate();
String url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + wechatAppId + "&secret="
java微信验证
于 2022-02-15 15:12:19 首次发布