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

How to place advertisements on Toutiao?

How to place ads on Toutiao? Advertising Process ...

Cat: I don't like razors, my whiskers are very sensitive

I am Dong Dong Meow Talking animals are so fun! T...

Zhejiang Asian Games | Plants also exercise series: Sensitivity causes "ADHD"

Diverse Asian civilizations have given birth to a...

Cook says Apple is considering allowing iOS users to delete pre-installed apps

[[149443]] According to foreign media reports, Ap...

iOS and open source: A red apricot blossoms

For most people, Apple and its iOS empire give pe...

APP Promotion Operation Manual Complete Strategy

Starting from the position of mobile Internet mar...

Kuaishou Operation Guide from 0 to 1

As the saying goes, "Everything is difficult...

Ahui's "Short Video Operation Practical Course" focuses on zero-based teaching

Course Catalog ├──001.How to enter the class.mp4 ...