NutzCN Logo
问答 微信新增图文接口空指针异常
发布于 2442天前 作者 qq_d6c9c504 1661 次浏览 复制 上一个帖子 下一个帖子
标签:
   public WxResp add_news(WxArticle... news) {
        return postJson("/material/add_news", new NutMap().put("articles", Arrays.asList(news)));
    }
	protected WxResp postJson(String uri, Object... args) {
		NutMap body = new NutMap();
		for (int i = 0; i < args.length; i += 2) {
			body.put(args[i].toString(), args[i + 1]);
		}
		return postJson(uri, body);
	}

越界了,请教下兽总是有问题还是我理解不对

12 回复

这个接口传入的对象的属性和官网不一致?应该是62版本中的WxMassArticle

新增永久图文素材
接口调用请求说明
http请求方式: POST,https协议
https://api.weixin.qq.com/cgi-bin/material/add_news?access_token=ACCESS_TOKEN
调用示例
{
  "articles": [{
       "title": TITLE,
       "thumb_media_id": THUMB_MEDIA_ID,
       "author": AUTHOR,
       "digest": DIGEST,
       "show_cover_pic": SHOW_COVER_PIC(0 / 1),
       "content": CONTENT,
       "content_source_url": CONTENT_SOURCE_URL
    },
    //若新增的是多图文素材,则此处应还有几段articles结构
 ]
}

报个issue或者发个pull req嘛

我更希望是后者 ^_^

好,没问题,这几天我搞下

@qq_d6c9c504 你是用最新版本的nutzwx么,我记得好像修复过,不知道可记错了。。

是的,你查下,还有个地方是错的

    /**
     * 这个地方官方有bug,要post body方式请求
     * @param media_id
     * @return
     */
    public NutResource get_material(String media_id) {
        String url = String.format("https://api.weixin.qq.com/cgi-bin/material/get_material?access_token=%s", getAccessToken());
        Request req = Request.create(url, Request.METHOD.POST);
        NutMap body = new NutMap();
        body.put("media_id", media_id);
        req.setData(Json.toJson(body));
        final Response resp = Sender.create(req).send();
        if (!resp.isOK())
            throw new IllegalStateException("download media file, resp code=" + resp.getStatus());
        String disposition = resp.getHeader().get("Content-disposition");
        return new WxResource(disposition, resp.getStream());
    }

https://github.com/nutzam/nutzwx/pull/29 两个大师帮看看,这是我们用接口越到的问题

是下个版本发布,还是已经上到62版本上了?

下一个版本,现在有快照版

添加回复
请先登陆
回到顶部