| | |
| | | // access_token接口https请求方式: GET |
| | | // https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET |
| | | |
| | | //改从redis中获取 |
| | | ValueOperations<String, String> valueOperations = stringRedisTemplate.opsForValue(); |
| | | log.info("appid:"+appid); |
| | | return valueOperations.get("access_token:access_token:" + appid); |
| | | |
| | | /* String path = " https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential"; |
| | | String path = " https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential"; |
| | | URL url = new URL(path + "&appid=" + appid + "&secret=" + secret); |
| | | HttpURLConnection connection = (HttpURLConnection)url.openConnection(); |
| | | connection.setRequestMethod("GET"); |
| | |
| | | |
| | | // System.out.println(sb.toString()); |
| | | in.close(); |
| | | return sb.toString();*/ |
| | | return sb.toString(); |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | if (!appidList.isEmpty()) { |
| | | for (int i = 0; i < appidList.size(); i++) { |
| | | String token = officialApi.getToken(appidList.get(i), secretList.get(i)); |
| | | log.info("通过appid:" + appidList.get(i) + "获取token返回参数:" + token); |
| | | if (StringUtils.isNotEmpty(token)) { |
| | | tokenList.add(token); |
| | | JSONObject tokenJson = JSON.parseObject(token); |
| | | if (StringUtils.isNotEmpty(tokenJson)) { |
| | | tokenList.add(tokenJson.getString("access_token")); |
| | | if (StringUtils.isNotEmpty(token)) { |
| | | tokenList.add(token); |
| | | } |
| | | } |
| | | } |
| | | } |