| | |
| | | return resultString; |
| | | } |
| | | |
| | | public static String getAccessToken() { |
| | | RestTemplate restTemplate = new RestTemplate(); |
| | | Map<String, String> params = new HashMap<>(); |
| | | params.put("APPID", "wx7c54942dfc87f4d8"); // |
| | | params.put("APPSECRET", "5873a729c365b65ab42bb5fc82d2ed49"); // |
| | | ResponseEntity<String> responseEntity = restTemplate.getForEntity( |
| | | "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={APPID}&secret={APPSECRET}", String.class, params); |
| | | String body = responseEntity.getBody(); |
| | | JSONObject object = JSON.parseObject(body); |
| | | String Access_Token = object.getString("access_token"); |
| | | String expires_in = object.getString("expires_in"); |
| | | System.out.println("有效时长expires_in:" + expires_in); |
| | | return Access_Token; |
| | | } |
| | | } |