/**
* 获取素材列表并存入集合中
* @param accessToken 获取接口凭证的唯一标识
* @param type 素材的类型,图片(image)、视频(video)、语音 (voice)、图文(news)
* @param offset 从全部素材的该偏移位置开始返回,0表示从第一个素材 返回
* @param count 返回素材的数量,取值在1到20之间
* @return
*/
private static JSONObject getMaterialList(String accessToken, String type, int offset, int count) {
// 1. 准备好JSON请求参数
Map<String, String> paramMap = new HashMap<>();
paramMap.put("type", type);
paramMap.put("offset", offset + "");
paramMap.put("count", count + "");
Object data = JSON.toJSON(paramMap);
// 2. 生成一个请求
String requestUrl = "https://api.weixin.qq.com/cgi-bin/material/batchget_material?access_token=" + accessToken;
// 使用POST方法进行请求
HttpPost httpPost = new HttpPost(requestUrl);
CloseableHttpClient httpClient =
发送HTTP请求示例--向微信公众号接口发送请求, 获取公众号素材列表
最新推荐文章于 2024-01-03 19:29:29 发布