String encode = URLEncoder.encode(pages);//根据需要转换
Map<String, Object> param = new HashMap<>();
param.put("access_token", AccessToken);
param.put("appname", "douyin");
param.put("path", encode);
param.put("width", 430);
param.put("set_icon", true);
RestTemplate rest = new RestTemplate();
InputStream inputStream = null;
OutputStream outputStream = null;
File file = null
String url = "https://developer.toutiao.com/api/apps/qrcode";
MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
HttpEntity requestEntity = new HttpEntity(param, headers);
ResponseEntity<byte[]> entity =
rest.exchange(url, HttpMethod.POST, requestEntity, byte[].class, new Object[0]);
if (entity.getStatusCodeValue() != 200) {
return "获取失败";
}
byte[] result = entity.getBody();
Spring RestTemplate请求第三方接口
最新推荐文章于 2023-07-04 19:45:00 发布