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

What should I do if my family or colleague is infected with the new coronavirus?

In recent days Multiple sporadic cases have occur...

How much does it cost to be an agent for Qian'an's online recharge mini program?

How much does it cost to be an agent for an onlin...

Analysis of WeChat Reading’s user growth strategy!

Even with the support of WeChat, a huge traffic p...

There are 3 basic ways to get traffic when promoting APP!

I have been working in operations for a year, and...

2021 China Advertising Market Trends

Overall Trends in the Advertising Market Accordin...

The most dangerous tree in the world

© Veselo.info Leviathan Press: I guess many of yo...

Is the pork stamp special? Can it be washed off once it is stamped?

Review expert: Wang Guoyi, Postdoctoral Fellow in...

A "tea-making party" that ignites your taste buds may quietly poison you

Your browser does not support the video tag What ...

Who is Zeng Hou Yi of Suizhou?

This is a Names not recorded in history books 197...

Google VP criticizes Apple iMessage for "green bubble bullying" of Android users

On the morning of January 8, the Wall Street Jour...

Say goodbye to iOS and common off-screen rendering!

The optimization of mobile applications mainly de...

The latest paper in Nature: Is it important to have water in your head?

In recent years, there is a "glymphatic clea...