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

Bilibili Operation: How to improve user loyalty?

With its content quality, community atmosphere, u...

Anniversary event planning: 5 steps from planning to implementation!

The growth of a person needs the blessing of birt...

In the wave of madness and impetuousness, will Apple fall behind the 5G era?

Some time ago, China Mobile announced that the fi...

How to build a brand? Brand building methodology!

Without a brand, your product will be trapped in ...

Product Operation: How to build a closed loop of content ecology?

Have you ever had this experience: you just start...

Operations: Where is the entry point to find accurate users? ?

one. Definition and classification of users 1. De...

Sharing Experience: Expression, Feedback and Stimulation in Game Design

[[150664]] It is a difficult process from the bir...

Let’s re-acquaint ourselves with Flutter in 2019

Now it is 2019, let's take a serious look at ...

Should I go to the hospital if I get COVID-19?

Source: Department of Critical Care Medicine, Zho...