|
@@ -25,7 +25,9 @@ import me.chanjar.weixin.mp.api.WxMpService;
|
|
|
import me.chanjar.weixin.mp.enums.WxMpApiUrl;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.boot.ExitCodeEvent;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
import org.springframework.web.servlet.view.RedirectView;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
@@ -281,11 +283,16 @@ public class WeChatController {
|
|
|
public String getWeChatAccessToken() {
|
|
|
try {
|
|
|
// 微信公众号官方获取AccessToken
|
|
|
- String accessToken = wxMpService.getAccessToken();
|
|
|
+ RestTemplate restTemplate = new RestTemplate();
|
|
|
+ String requestParams = String.format(constant.WE_CHAT_ACCESS_TOKEN_URL, constant.WE_CHAT_APP_ID, constant.WE_CHAT_SECRET);
|
|
|
+ ResponseEntity<String> responseEntity = restTemplate.getForEntity(requestParams, String.class);
|
|
|
+
|
|
|
+ String accessToken = JSONObject.parseObject(responseEntity.getBody()).getString("access_token");
|
|
|
+ log.info("we_chat_access_token: " + accessToken);
|
|
|
|
|
|
return accessToken;
|
|
|
} catch (Exception e) {
|
|
|
-
|
|
|
+ log.info("异常信息:{}", e);
|
|
|
}
|
|
|
return null;
|
|
|
}
|