问题描述
- 微信 群发 上传图文素材44003
-
// 存放所有文章结合list的map HashMap allMap = new HashMap(); // 存放所有文章的list List<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>(); // 各个文章的map HashMap<String, String> map; HashMap<String, String> map1; // 缩略图的id String thumb_media_id = "qQqbYn8mE_ZkajO3m2RCzZWUobzFSMbILv7KoY1lzyKEK_ypL1WcLFAXtcI6oVxp"; map = new HashMap<String, String>(); map.put("thumb_media_id", thumb_media_id); map.put("author", "xiaojin"); map.put("title", "上传群发测试"); map.put("content_source_url", "www.eupwood.com"); map.put("content", "这是测试内容1"); map.put("digest", "测试用描述"); map.put("show_cover_pic", "1"); map1 = new HashMap<String, String>(); map1.put("thumb_media_id", thumb_media_id); map1.put("author", "xiaojin"); map1.put("title", "上传群发测试1"); map1.put("content_source_url", "www.eupwood.com"); map1.put("content", "这是测试内容2"); map1.put("digest", "测试用描述1"); map1.put("show_cover_pic", "0"); list.add(map); list.add(map1); allMap.put("articles", list); JSONArray postData = JSONArray.fromObject(allMap); HttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost("https://api.weixin.qq.com/cgi-bin/media/uploadnews?access_token=" + token); StringEntity se = new StringEntity(postData.toString()); httpPost.setEntity(se); HttpResponse response = httpClient.execute(httpPost); int result = response.getStatusLine().getStatusCode(); if (result == HttpStatus.SC_OK) { System.out.println("OK"); HttpEntity resEntity = response.getEntity(); System.out.println(EntityUtils.toString(resEntity)); System.out.println(resEntity.getContent()); EntityUtils.consume(resEntity); }
代码如上,图文内容是有的,难道是我post的有问题????
解决方案
时间: 2024-11-01 09:36:10