|
@@ -9,6 +9,9 @@ import com.template.config.WeixiaoConfig;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
|
|
+import org.springframework.http.HttpEntity;
|
|
|
|
|
+import org.springframework.http.HttpHeaders;
|
|
|
|
|
+import org.springframework.http.MediaType;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
import org.springframework.web.client.RestTemplate;
|
|
@@ -101,7 +104,15 @@ public class WeiXiaoComponent {
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
RestTemplate client = new RestTemplate();
|
|
RestTemplate client = new RestTemplate();
|
|
|
- ResponseEntity<String> tokenResponse = client.postForEntity(uri, tokenParams, String.class);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // wecode换取token
|
|
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
|
|
+ headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
|
+ HttpEntity<Map<String, String>> request = new HttpEntity<>(tokenParams, headers);
|
|
|
|
|
+
|
|
|
|
|
+ ResponseEntity<String> tokenResponse = client.postForEntity(uri, request, String.class);
|
|
|
|
|
+
|
|
|
|
|
+// ResponseEntity<String> tokenResponse = client.postForEntity(uri, tokenParams, String.class);(需要加头部)
|
|
|
String body = tokenResponse.getBody();
|
|
String body = tokenResponse.getBody();
|
|
|
log.info("微校请求token返回结果【{}】", body);
|
|
log.info("微校请求token返回结果【{}】", body);
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
ObjectMapper mapper = new ObjectMapper();
|