Appearance
下载图片
按图片消息回调里的 XML 下载图片,返回图片地址。
接口地址: POST /getMsgImg
说明与注意
content传回调里的整段 XML,不要只复制其中部分字段。- 不是每张图都同时有常规图和高清图,下载失败时换
type重试。
请求参数
| 参数名 | 必选 | 类型 | 说明 |
|---|---|---|---|
| wId | 是 | string | 登录实例标识 |
| msgId | 是 | number | 消息 ID |
| content | 是 | string | 图片消息回调中的 XML 数据 |
| type | 否 | int | 图片类型:0 常规图片,1 高清图 |
请求示例
http
POST {BASE_URL}/getMsgImg
Authorization: Bearer <你的调用凭证>
Content-Type: application/json
{
"wId": "{{wId}}",
"msgId": 1102684156,
"content": "<?xml version=\"1.0\"?><msg><img aeskey=\"07fea09b27952d512c0d71a52c914f3\" cdnthumburl=\"305802010004...\" cdnmidimgurl=\"305802010004...\" length=\"51361\" md5=\"449fb858f24416adcab831859011fb21\" /></msg>",
"type": 0
}bash
curl -X POST '{BASE_URL}/getMsgImg' \
-H 'Authorization: Bearer <你的调用凭证>' \
-H 'Content-Type: application/json' \
--data-raw '{
"wId": "{{wId}}",
"msgId": 1102684156,
"content": "<?xml version=\"1.0\"?><msg><img aeskey=\"07fea09b27952d512c0d71a52c914f3\" cdnthumburl=\"305802010004...\" cdnmidimgurl=\"305802010004...\" length=\"51361\" md5=\"449fb858f24416adcab831859011fb21\" /></msg>",
"type": 0
}'python
import requests
url = "{BASE_URL}/getMsgImg"
headers = {"Authorization": "Bearer <你的调用凭证>", "Content-Type": "application/json"}
body = r"""{
"wId": "{{wId}}",
"msgId": 1102684156,
"content": "<?xml version=\"1.0\"?><msg><img aeskey=\"07fea09b27952d512c0d71a52c914f3\" cdnthumburl=\"305802010004...\" cdnmidimgurl=\"305802010004...\" length=\"51361\" md5=\"449fb858f24416adcab831859011fb21\" /></msg>",
"type": 0
}"""
resp = requests.post(url, headers=headers, data=body.encode("utf-8"))
print(resp.text)java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
String url = "{BASE_URL}/getMsgImg";
String body = "{\n" +
" \"wId\": \"{{wId}}\",\n" +
" \"msgId\": 1102684156,\n" +
" \"content\": \"<?xml version=\\\"1.0\\\"?><msg><img aeskey=\\\"07fea09b27952d512c0d71a52c914f3\\\" cdnthumburl=\\\"305802010004...\\\" cdnmidimgurl=\\\"305802010004...\\\" length=\\\"51361\\\" md5=\\\"449fb858f24416adcab831859011fb21\\\" /></msg>\",\n" +
" \"type\": 0\n" +
"}";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder(URI.create(url))
.header("Authorization", "Bearer <你的调用凭证>")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());php
<?php
$url = '{BASE_URL}/getMsgImg';
$body = <<<'JSON'
{
"wId": "{{wId}}",
"msgId": 1102684156,
"content": "<?xml version=\"1.0\"?><msg><img aeskey=\"07fea09b27952d512c0d71a52c914f3\" cdnthumburl=\"305802010004...\" cdnmidimgurl=\"305802010004...\" length=\"51361\" md5=\"449fb858f24416adcab831859011fb21\" /></msg>",
"type": 0
}
JSON;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer <你的调用凭证>',
'Content-Type: application/json',
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;成功响应
json
{
"code": "1000",
"message": "成功",
"data": {
"url": "https://cdn.e-yun.example/msgImg/dd32565c-78b0-4803-a330-6293b05674d9.png"
}
}错误响应
json
{
"code": "1001",
"message": "失败",
"data": null
}响应参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| code | string | 1000 成功;其他值都是失败,通常是 1001 |
| message | string | 反馈信息 |
| data | object | 下载结果 |
| data.url | string | 图片地址,通常 7 日内有效 |