| | |
| | | String body1 = exchange.getBody(); |
| | | return body1; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取小程序urllink码 |
| | | * env_version 默认值"release"。要打开的小程序版本。正式版为 "release",体验版为"trial",开发版为"develop",仅在微信外打开时生效。 |
| | | * @return |
| | | */ |
| | | public String getUrlLink(String path, String query, String env_version) throws Exception{ |
| | | String wxAppletsAccessToken = redisUtil.getValue("wxAppletsAccessToken"); |
| | | String url = "https://api.weixin.qq.com/wxa/generate_urllink?access_token=" + wxAppletsAccessToken; |
| | | Map<String, Object> param = new HashMap<>(); |
| | | param.put("path", path); |
| | | param.put("query", query); |
| | | param.put("is_expire", true); |
| | | param.put("expire_type", 0); |
| | | param.put("expire_time", System.currentTimeMillis() + 60 * 60 * 1000); |
| | | param.put("env_version", env_version); |
| | | HttpHeaders httpHeaders = new HttpHeaders(); |
| | | MediaType type=MediaType.parseMediaType("application/json;charset=UTF-8"); |
| | | httpHeaders.setContentType(type); |
| | | HttpEntity<Map<String, Object>> requestEntity = new HttpEntity<>(param, httpHeaders); |
| | | ResponseEntity<String> exchange = restTemplate.exchange(url, HttpMethod.POST, requestEntity, String.class); |
| | | String body1 = exchange.getBody(); |
| | | return body1; |
| | | } |
| | | } |