|
|
@@ -18,7 +18,7 @@ import java.io.IOException;
|
|
|
* @date 2024/6/20 19:16
|
|
|
*/
|
|
|
public class StHttpRequest {
|
|
|
- public static String postHttpClient(String path, String json) throws Exception {
|
|
|
+ public static String postHttpClient(String path, String json,String token) throws Exception {
|
|
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
|
|
String uri = path;
|
|
|
try {
|
|
|
@@ -28,7 +28,7 @@ public class StHttpRequest {
|
|
|
entity.setContentType("application/json"); // 设置请求的内容类型
|
|
|
httpPost.setEntity(entity);
|
|
|
// 添加请求头
|
|
|
- httpPost.addHeader("X-Access-Token", StpUtil.getTokenValue()); // 添加eventId请求头
|
|
|
+ httpPost.addHeader("X-Access-Token", token);
|
|
|
// 执行请求并获取响应
|
|
|
CloseableHttpResponse response = httpClient.execute(httpPost);
|
|
|
try {
|
|
|
@@ -46,13 +46,14 @@ public class StHttpRequest {
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
- public static String getHttpClient(String path) throws Exception {
|
|
|
+
|
|
|
+ public static String getHttpClient(String path,String token) throws Exception {
|
|
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
|
|
String uri = path;
|
|
|
try {
|
|
|
HttpGet httpGet = new HttpGet(uri); // 替换为你的目标URL
|
|
|
// 添加请求头
|
|
|
- httpGet.addHeader("X-Access-Token", StpUtil.getTokenValue()); // 添加eventId请求头
|
|
|
+ httpGet.addHeader("X-Access-Token", token);
|
|
|
// 执行请求并获取响应
|
|
|
CloseableHttpResponse response = httpClient.execute(httpGet);
|
|
|
try {
|