登录

php - 微信上传永久素材报错

上传临时素材就没有问题

        $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内容错误
可是我没有发送哪里出错了
有人知道是什么原因吗?

# PHP
PHPzhongPHPzhong2054 天前622 次浏览

全部回复(1) 我要回复

  • 阿神

    阿神2017-04-11 10:24:02

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

         格式:
    
    {
      "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段
     ]
    }
    

    回复
    0
  • 取消回复发送