How to manage multimedia files in WeChat Enterprise Account Development

How to manage multimedia files in WeChat Enterprise Account Development

When using the interface, enterprises can obtain and call multimedia files and multimedia messages through media_id. Through this interface, enterprises can upload or download multimedia files.

Note that each multimedia file (media_id) will be automatically deleted 3 days after being uploaded to the WeChat server to save server resources.

1. Upload media files

Used to upload media resource files such as pictures, audio, video, and common files (such as doc, ppt). The interface returns the media resource ID: media_id. Please note that media_id is reusable, and the same media_id can be used to send messages multiple times .

  • Request Instructions

Https request method: POST

https://qyapi.weixin.qq.com/cgi-bin/media/upload?access_token=ACCESS_TOKEN&type=TYPE

  • Parameter Description
parameter must illustrate
access_token yes Call interface credentials
type yes Media file types, including image, voice, video, and file
media yes Media file identifier in form-data, including filename, filelength, content-type, etc.
  • Permissions

Completely public. All administrators can call it, and media_id can be shared.

  • Return Description
  1. {
  2. "type" : "image" ,
  3. "media_id" : "0000001" ,
  4. "created_at" : "1380000000"  
  5. }
parameter illustrate
type Media file types, including image, voice, video, and file
media_id The *** identifier obtained after the media file is uploaded
created_at Media file upload timestamp
  • Uploaded media file limit

Image: 1MB, support JPG format

Voice: 2MB, playback length no more than 60s, supports AMR format

Video: 10MB, supports MP4 format

Normal file: 10MB

2. Get media files

Get pictures, audio, video and other files through media_id.

  • Request Instructions

Https request method: GET

https://qyapi.weixin.qq.com/cgi-bin/media/get?access_token=ACCESS_TOKEN&media_id=MEDIA_ID

  • Parameter Description
parameter must illustrate
access_token yes Call interface credentials
media_id yes Media file id
  • Permissions

Completely public. All administrators can call it, and media_id can be shared.

  • Return results

a) Return if correct:

  1. {
  2. HTTP/ 1.1   200 OK
  3. Connection: close
  4. Content-Type: image/jpeg
  5. Content-disposition: attachment; filename= "MEDIA_ID.jpg"  
  6. Date: Sun, 06 Jan 2013   10 : 20 : 18 GMT
  7. Cache-Control: no-cache, must-revalidate
  8. Content-Length: 339721  
  9.     
  10. Xxxx
  11. }

b) Returned in case of error (HTTP header is omitted here):

  1. {
  2. "errcode" : "40004" ,
  3. "errmsg" : "invalid media_id"  
  4. }

<<:  Google engineers teach: Top 10 things new developers must invest in

>>:  How to receive messages in WeChat Enterprise Account Development

Recommend

Horror movie comes true: flood, more than 70 crocodiles escape...

On September 11, a video circulated online said t...

The relationship between programmer growth and the number of lines of code

In 2011, John D. Cook wrote a blog post in which ...

8 things independent developers should know before entering the industry

[[153964]] About five months ago, I decided to qu...

OCPC bidding strategy!

As the threshold of the ocpc model gradually decr...

Tik Tok operation plan and strategy skills

The popularity of Douyin is unquestionable, so ho...

Xiaxie American English Pronunciation Class for Beginners

Resources of Xiaxie American English Pronunciatio...

As flu season approaches, how should we get vaccinated?

Produced by: Science Popularization China Author:...

Short videos + full links, a new way of marketing movies in 2020

2020 was a turbulent year for the film industry. ...

Mixue Ice City brand upgrade marketing strategy case

The only martial arts in the world that cannot be...

How to do UGC operation? Sort out these 3 points!

UGC has been recognized as a way to improve produ...

User Operation: How to create a To B user portrait?

Why do we need to create user portraits? How to c...