java
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
public class HttpClientExample {
public static void main(String[] args) {
HttpClient httpClient = HttpClientBuilder.create().build();
String url = "e.com/api";
try {
HttpGet request = new HttpGet(url);
// 设置请求参数
request.addHeader("Authorization", "Bearer your_access_token");
HttpResponse response = httpClient.execute(request);
// 处理响应
// TODO: 处理接口响应内容
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
顶一下
(0)
0%
踩一下
(0)
0%
- 相关评论
- 我要评论
-
上一篇:返回栏目
下一篇:java -jar 报错