# Upload Pictures
# Dxplaination of Interface Call Request
http请求方式:POST
https://api.weixin.qq.com/product/img/upload?access_token=xxxxxxxxx&upload_type=0&resp_type=0&height=108&width=108
# URL Request Parameter Dxplaination
parameter | type | Is it compulsory? | Introductions |
---|---|---|---|
upload_type | number | yes | Upload type: 0-binary stream, 1-image url |
resp_type | number | yes | Return data type: 0-media_id and pay_media_id, 1-Image link ( Item info [ ] Make sure to use this parameter to get links) |
height | number | no | Upload_type = 0 Required, image height, pixels |
width | number | no | Required for upload_type = 0, width of image, pixels |
Image upload size limit
resp_type = 0: 2MB
resp_type = 1: 10MB
# POST Packet Request Parameter Dxplaination
parameter | type | Is it compulsory? | Introductions |
---|---|---|---|
img_url | string | no | Upload_type = 1 Required, image url |
# Request Example 1
curl -F media=@test.jpg "https://api.weixin.qq.com/product/img/upload?access_token=xxxxxxxxx&upload_type=0&resp_type=0&height=108&width=108"
# Back-up Example 1
{
"errcode": 0,
"errmsg":"ok",
"pic_file":
{
"media_id": "xlvjalsdhgas",
"pay_media_id": "asdgasvdadfa"
}
}
# Request Example 2
curl -d "{\"img_url\":\"https://URL地址/yyy\"}" "http://api.weixin.qq.com/product/img/upload?access_token=xxxxxxxxx&upload_type=1&resp_type=1"
# Back-up Example 2
{
"errcode":0,
"pic_file":
{
"temp_img_url": "xxxxx"
}
}
# Be careful
Resp_type = 1
will return something likemmecimage.cn/p/{ AppID }/{ img Key}
A link to a picture, which is permanently valid, and the same picture does not need to be repeatedly uploaded without a repeat call to the interface.- The image link returned by the interface has an access frequency limit, beyond which the
404
status code is returned. Do not use the image link for client-side (largely accessed) display.
- Current access frequency limit rules:
AppID
Dimension: 10000 / min.img Key
Dimension: 100 / min.
- Interface to support picture processing (zoom / cut / compression / watermark, etc.)Specific usage reference document: https://cloud.tencent.com/document/product/460/53505, the
download_url
is the link to the image returned by the current interface
# Dxplaination of callback parameters
参数 | type | Introductions |
---|---|---|
errcode | number | Error code |
errmsg | string | Error message |
pic_file.media_id | number | media_id |
pic_file.pay_media_id | string | Payment media_id |
temp_img_url | string | Image temporary url |
# Return code
返回码 | Error Type |
---|---|
-1 | System exceptions |
-2 | Token too long |
600201 | This link does not need to be converted and can be used directly (domain namestore.mp. video.tencent-cloud.com ,Or url prefixmmbizurl.cn / p / , or url prefixmmecimage.cn / p / ) |
101002 | Image size exceeds limit,resp_type = 0: 2MB ,resp_type − 1: 10MB |