微信上传永久素材报错

上传临时素材就没有问题

        $filePath = '../../1.jpg';
        $type = "image";
        // $type = "thumb";
        $filedata = array("media"=>"@".$filePath);
        //这个是上传永久素材的
       // $url = "https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=$this->access_token&type=".$type;
         //这个是上传临时素材,没有问题
        // $url = "http://file.api.weixin.qq.com/cgi-bin/media/upload?access_token=".$this->access_token."&type=".$type;
        $url = 'https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=' . $this->access_token . '&type=' . $type;                
        $result = $this->post($url,$filedata);
        // media_id = 'HJQDe3hEZ8zdO7BGmaAVd8QS27T3jzXGG4yc5sgiOhLlXWaa7VFtkHxisBErGo_8';
        var_dump($result);

上传永久素材就报下面这个错误

string(69) "{"errcode":47001,"errmsg":"data format error hint: [8POVxa0531e565]"}"

微信文档说的是 解析JSON/XML内容错误
可是我没有发送哪里出错了
有人知道是什么原因吗?

阅读 3k
1 个回答

这里的错误是指你组装的数据格式错误,好好对比下文档,看下自己哪里错误了。

     格式:

{
  "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结构,最多8段
 ]
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题