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

Are there "traps" on your computer desk? Beware of "mouse hand"!

1. What is “mouse hand”? "Mouse hand", ...

A man's action caused more than 30 cars to burn! Be careful recently

As the weather warms up The unbearable "flyi...

What? Turner and Monet paintings can also be used to study air pollution!

Perhaps you will say: Shouldn’t air be colorless ...

Microsoft Office iOS version is now available on the App Store

Microsoft had previously announced that it would ...

"Douyin Data Operation Series" Douyin Live Streaming Room Detonation Algorithm

Training course content: The course starts with w...

9 methods for selecting topics for short video operations, super comprehensive!

In short video creation, topic selection means th...

Take a bite of the pagoda vegetable and the fractal secret behind it is...

As the weather warms up, I put away my thick cott...

This AR technology will "dissect" you alive for others to see

Generally speaking, if a physical therapist wants...