Material management

Usage scenarios

In the enterprise wechat API interface, developers need to use customized resources, such as sending local picture messages, setting the address book to customize the profile picture, and so on. In order to realize the resource file, one upload can be used for multiple times, provides the material management interface: media_ID to identify the resource file, realize the file upload and download.

Upload temporary material

A debugging tool

The media_id is only valid for three days

Media_id can be shared between applications within the same enterprise

Request method: POST (HTTPS) Request address: qyapi.weixin.qq.com/cgi-bin/med…

1. Obtain access_token

This is equivalent to creating a login credential. Other service APIS rely on the Access_token to authenticate the identity of the caller

2. Upload the temporary file

You can select the type of file to upload

Image is selected by default

Fill in the access_token

Select the type of file to upload

Upload the file you want to upload

Calling the interface returns the following data

 {
   "errcode":0,
   "errmsg":"ok",
   "type":"image",
   "media_id":"31d1e0gkY26St0YSZK0kgXnZO6pWEqDWCTCO4q-kHcW0",
   "created_at":"1627737122"
 }
Copy the code
  • Media_id: unique id obtained after a media file is uploaded. The value is valid within 3 days
  • Created_at: indicates the time stamp of media file uploading

Get media_id: 31 d1e0gky26st0yszk0kgxnzo6pweqdwctco4q – kHcW0

3. Restrictions on uploaded media files

All files must be larger than 5 bytes

  • Image: 2MB. JPG or PNG format
  • Voice: 2MB. The playback length does not exceed 60 seconds. Only the AMR format is supported
  • Video: 10MB, MP4 format
  • Common files: 20MB

To upload pictures

A debugging tool

Gets the image URL, which is permanently valid

It can only be used to display pictures in the text message body or send greetings to customers

Note: Images will be blocked if used in non-corporate wechat environment.

Request method: POST (HTTPS) Request address: qyapi.weixin.qq.com/cgi-bin/med…

1. Obtain access_token

The method is the same as uploading temporary material

2. Upload pictures

Fill in the access_token

Select the image you want to upload

The call interface returns a value

 {
   "errcode":0,
   "errmsg":"ok",
   "url":"https://wework.qpic.cn/wwpic/496678_-XVKHvLWS9ucJJ4_1627737613/0"
 }
Copy the code
  • Errcode: Indicates the return code
  • Errmsg: Text description of the return code
  • Url: Indicates the URL of the uploaded image. permanent

Get the url: https://wework.qpic.cn/wwpic/496678_-XVKHvLWS9ucJJ4_1627737613/0

After uploading, you can view the image in the browser through the URL

3. Limit the size of uploaded images

The image file size should be between 5B and 2MB

Get temporary footage

A debugging tool

Request method: GET (HTTPS) Request address: qyapi.weixin.qq.com/cgi-bin/med…

1. Obtain access_token

The method is the same as uploading temporary material

2. Get temporary material

Fill in the access_token

Fill in the media_ID obtained from uploading temporary footage earlier

(31d1e0gkY26St0YSZK0kgXnZO6pWEqDWCTCO4q-kHcW0)

Call the interface to get the previously uploaded temporary material

Get hd audio footage

The method is consistent with the method of obtaining temporary material