微信公众号-获取素材列表 返回40004或40007问题 {errcode":40004,"errmsg":"invalid media type hint:"}
官方文档链接:https://developers.weixin.qq.com/doc/offiaccount/Asset_Management/Get_materials_list.html
如官方文档的调用示例 参数传json格式即可
//获取公众号素材列表Url public static final String MATERIAL_GET_URL = "https://api.weixin.qq.com/cgi-bin/material/batchget_material?access_token=ACCESS_TOKEN"; /** * 获取公众号素材列表 * @param type * @param offset * @param count * @return */ public String getMaterial(String type,Integer offset,Integer count)
String accessToken = SignUtil.getAccessToken(); Map<String, Object> map = new HashMap<>(); map.put("type",type); map.put("offset",offset); map.put("count",count); return HttpUtil.post(MATERIAL_GET_URL.replace("ACCESS_TOKEN", accessToken), JSON.toJSONString(map)); }
返回:
{ "item": [ { "media_id": "5pg7xLonbBEUcMlZUTp08ejjPo1clpOD3jZSFuslaDLyhdUYrk-nN_Krc8PEmYjE", "name": "图片.png", "update_time": 1648435841, "url": "https://mmbiz.qpic.cn/mmbiz_png/ZMe4qSlbjGHVJ9fk9dSzvtImdq0vNGaH26bicbNId0ego5iba6uswq5JqnRp5psWrZiaahysSmXsKxnSGbl29bQIg/0?wx_fmt=png", "tags": [] } ], "total_count": 1, "item_count": 1 }