search

Home  >  Q&A  >  body text

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

上传临时素材就没有问题

1

2

3

4

5

6

7

8

9

10

11

12

<code>        $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);</code>

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

1

2

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

</code>

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

PHPzPHPz2954 days ago1026

reply all(1)I'll reply

  • 阿神

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

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

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    12

    13

    14

    15

    16

    <code>     格式:

     

    {

      "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段

     ]

    }

    </code>

    reply
    0
  • Cancelreply