Add permanent material


Add permanent material

In addition to temporary materials that will expire in 3 days, developers sometimes need to save some materials permanently. At that time, they can add permanent materials through this interface. material.

Recently updated, after the permanent picture material is added, the URL will be returned to the developer. The developer can use it within the Tencent domain name (if used outside the Tencent domain name, the picture will be blocked).

Please note:

1. The newly added permanent materials can also be seen in the material management module of the official website of the public platform

2. The number of permanent materials is If there is an upper limit, please add it with caution. The upper limit of graphic message materials and picture materials is 5000, and the upper limit of other types is 1000

3. The format and size of the materials are consistent with the official website of the public platform. Specifically, the image size does not exceed 2M, supports bmp/png/jpeg/jpg/gif format, the voice size does not exceed 5M, the length does not exceed 60 seconds, and supports mp3/wma/wav/amr format

4, Calling this interface requires https protocol

Add permanent graphics and text materials

Interface call request instructions

##http request method: POST

https://api.weixin.qq.com/cgi-bin/material/add_news?access_token=ACCESS_TOKEN

Call example

{

"articles": [{

"title": TITLE,

"thumb_media_id": THUMB_MEDIA_ID,

"author": AUTHOR,

"digest": DIGEST,

"show_cover_pic": SHOW_COVER_PIC(0 / 1),

"content": CONTENT,

"content_source_url": CONTENT_SOURCE_URL

},

//If the new material is multiple graphics and text, there should be several articles structures here

]

}

Parameter Description

is the specific content of the ##content_source_url graphic message, that is, click "Read the original text" The following URL

Return instructions

{
"media_id":MEDIA_ID
}

The returned is the media_id of the newly added graphic message material.

Please note that in the specific content of graphic messages, external image links will be filtered. Developers can upload images through the following interface to obtain the URL and put them into graphic content for use.

Upload the picture in the graphic message to obtain the URL Please note that the pictures uploaded by this interface do not occupy the 5,000 limit of the number of pictures in the public account's material library. Images only support jpg/png format, and the size must be less than 1MB.

Interface call request description

http request method: POST

https://api.weixin.qq.com/cgi- bin/media/uploadimg?access_token=ACCESS_TOKEN

Call example (use curl command to upload an image using FORM form):

curl -F media=@test.jpg "https:/ /api.weixin.qq.com/cgi-bin/media/uploadimg?access_token=ACCESS_TOKEN"

Parameter Description

ParameterIs it necessaryDescription
title istitle
thumb_media_id is the cover picture material id of the graphic message (must be a permanent mediaID)
authorauthor
digestSummary of graphic and text messages. Only single graphic and text messages have abstracts. Multiple graphic and text messages are left empty.
##show_cover_pic is whether to display the cover, 0 is false, that is, it is not displayed, 1 is true, that is, it is displayed
##content graphic message. It supports HTML tags and must be less than 20,000 characters and less than 1M, and JS# will be removed here.
is the original address of the

Return instructions The return result under normal circumstances is:

{

"url": "http://mmbiz.qpic.cn/ mmbiz/gLO17UPS6FS2xsypf378iaNhWacZ1G1UplZYWEYfwvuU6Ont96b1roYs CNFwaRrSaKTPCUdBK9DgEHicsKwWCBRQ/0"

}

The url is the URL of the uploaded image, which can be used in subsequent group sending and placed in graphic messages.

Add other types of permanent materials

Interface call request instructions

Call the interface through the POST form, the form id is media, contains the material content that needs to be uploaded, including filename, filelength, content-type and other information. Please note: Picture materials will enter the default group in the material management module of the official website of the public platform.

http request method: POST, need to use https

https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=ACCESS_TOKEN&type=TYPE

Call example (use the curl command to add another type of permanent material using the FORM form. Please refer to the information for the use of the curl command)

Parameter Description

ParameterIs it necessaryDescription
access_token isCall interface credentials
media is the media file identifier in ##form-data, including filename, filelength, content-type and other information

Special attention should be paid to adding permanent video materials

When uploading video materials, you need to POST another form with the id of description, which contains the description information of the material. The content format is JSON and the format is as follows:

{
"title":VIDEO_TITLE,
"introduction":INTRODUCTION
}

Call example of adding permanent video material:

curl "https:/ /api.weixin.qq.com/cgi-bin/material/add_material?access_token=ACCESS_TOKEN&type=TYPE" -F media=@media.file -F description='{"title":VIDEO_TITLE, "introduction":INTRODUCTION}'

Parameter Description

ParameterIs it requiredDescription
access_tokenis调用接口凭证
type媒体文件类型,分别有图片(image)、语音(voice)、视频(video)和缩略图(thumb)
media is the media file identifier in ##form-data, including filename, filelength, content-type and other information
ParameterIs it necessaryDescription
title is the title of the video material
introduction is the description of the video material

Return description

{
"media_id":MEDIA_ID,
"url":URL
}

Return parameter description

ParametersDescription
media_idThe media_id of the new permanent material
urlThe image URL of the newly added image material (this field will be returned only when adding image material)

An example of the returned JSON data packet in error conditions is as follows (the example is an invalid media type error):

{"errcode":40007,"errmsg":"invalid media_id"}