public WxResp add_video(File f, String title, String introduction) {
if(f == null) {
throw new NullPointerException("meida file is NULL");
} else {
String url = String.format("https://api.weixin.qq.com/cgi-bin/media/add_material?access_token=%s", new Object[]{this.getAccessToken()});
Request req = Request.create(url, METHOD.POST);
req.getParams().put("media", f);
req.getParams().put("description", Json.toJson((new NutMap()).setv("title", title).setv("introduction", introduction), JsonFormat.compact().setQuoteName(true)));
Response resp = (new FilePostSender(req)).send();
if(!resp.isOK()) {
throw new IllegalStateException("add_material, resp code=" + resp.getStatus());
} else {
return (WxResp)Json.fromJson(WxResp.class, resp.getReader("UTF-8"));
}
}
}
2 回复
@wendal 谢谢兽总,我试试
添加回复
请先登陆