//package com.stylefeng.guns.modular.system.util;
|
//
|
//import com.alibaba.fastjson.JSON;
|
//import com.alibaba.fastjson.JSONObject;
|
//import com.stylefeng.guns.core.util.ToolUtil;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.http.HttpEntity;
|
//import org.springframework.http.ResponseEntity;
|
//import org.springframework.stereotype.Component;
|
//
|
//import java.util.HashMap;
|
//import java.util.Map;
|
//
|
//@Component
|
//public class UrlLinkUtil {
|
// @Autowired
|
// private HttpClientUtil httpClientUtil;
|
//
|
// @Autowired
|
// private RedisUtil redisUtil;
|
// public String getWxAppletsAccessToken() throws Exception{
|
// String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + "wxc89ecab90d24edd8" + "&secret=" + "bca863174d22736a4a9758a67484947e";
|
// String s = httpClientUtil.pushHttpRequset("GET", url, null, null, "form");
|
// if(ToolUtil.isEmpty(s)){
|
// return null;
|
// }
|
// JSONObject jsonObject = JSON.parseObject(s);
|
// return jsonObject.getString("access_token");
|
// }
|
//
|
// public String getUrlLink(String path, String query) 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("expire_type", 1);
|
// param.put("expire_interval", 1);
|
// param.put("path", path);
|
// param.put("query", query);
|
// param.put("env_version", "release");
|
// 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;
|
// }
|
//
|
//
|
//}
|