Appearance
群发助手-发送(待发送消息)
把「待发送」队列里的某条任务真正下发。
请求参数
| 参数 | 必填 | 类型 | 说明 |
|---|---|---|---|
appid | 是 | string | 实例 appid,标识操作哪个已登录账号。示例:we_xxxxxxxxxxxxxxx |
id | 是 | int64 | 取自获取待发送群发列表的待发送项 id。示例:117159486110430465 |
contentList | 否 | array<object> | 必须原样取自获取待发送群发列表返回的待发送项,含 appInfo,不能自己拼。示例:[{"contentType":0,"content":[{"type":0,"text":"示例文本"}],"a… |
conversationType | 是 | int64 | 0 客户 / 1 群。示例:0 |
contentList[] 字段
| 字段 | 类型 | 说明 |
|---|---|---|
contentList[].contentType | int64 | 消息类型码(0 文本/14 图片/23 视频…) |
contentList[].content | array<object> | 消息内容;文本为数组、媒体为对象 |
contentList[].content[].type | int64 | 类型编码(具体含义随所在对象:成员/部门、图片/视频、节点类型等,详见对应接口) |
contentList[].content[].text | string | type 0/3 的文本内容 |
contentList[].appInfo | string | 企微内部透传串(base64);群发/待发送场景需回填,业务方不必解析 |
请求示例
http
POST {BASE_URL}/wx-api/api/message/groupSendPending
Authorization: Bearer <你的 App Token>
Content-Type: application/json
{
"appid": "we_xxxxxxxxxxxxxxx",
"id": 117159486110430465,
"contentList": [
{
"contentType": 0,
"content": [
{
"type": 0,
"text": "示例文本"
}
],
"appInfo": "CAQQiaO51AYY4Y+oq5SAgAMg56GIsQQ="
}
],
"conversationType": 0
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
bash
curl -X POST '{BASE_URL}/wx-api/api/message/groupSendPending' \
-H 'Authorization: Bearer <你的 App Token>' \
-H 'Content-Type: application/json' \
--data-raw '{
"appid": "we_xxxxxxxxxxxxxxx",
"id": 117159486110430465,
"contentList": [
{
"contentType": 0,
"content": [
{
"type": 0,
"text": "示例文本"
}
],
"appInfo": "CAQQiaO51AYY4Y+oq5SAgAMg56GIsQQ="
}
],
"conversationType": 0
}'1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
python
import requests
url = "{BASE_URL}/wx-api/api/message/groupSendPending"
headers = {"Authorization": "Bearer <你的 App Token>", "Content-Type": "application/json"}
body = """{
"appid": "we_xxxxxxxxxxxxxxx",
"id": 117159486110430465,
"contentList": [
{
"contentType": 0,
"content": [
{
"type": 0,
"text": "示例文本"
}
],
"appInfo": "CAQQiaO51AYY4Y+oq5SAgAMg56GIsQQ="
}
],
"conversationType": 0
}"""
resp = requests.post(url, headers=headers, data=body.encode("utf-8"))
print(resp.text)1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
String url = "{BASE_URL}/wx-api/api/message/groupSendPending";
String body = "{\n" +
" \"appid\": \"we_xxxxxxxxxxxxxxx\",\n" +
" \"id\": 117159486110430465,\n" +
" \"contentList\": [\n" +
" {\n" +
" \"contentType\": 0,\n" +
" \"content\": [\n" +
" {\n" +
" \"type\": 0,\n" +
" \"text\": \"示例文本\"\n" +
" }\n" +
" ],\n" +
" \"appInfo\": \"CAQQiaO51AYY4Y+oq5SAgAMg56GIsQQ=\"\n" +
" }\n" +
" ],\n" +
" \"conversationType\": 0\n" +
"}";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder(URI.create(url))
.header("Authorization", "Bearer <你的 App Token>")
.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());1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
php
<?php
$url = '{BASE_URL}/wx-api/api/message/groupSendPending';
$body = <<<'JSON'
{
"appid": "we_xxxxxxxxxxxxxxx",
"id": 117159486110430465,
"contentList": [
{
"contentType": 0,
"content": [
{
"type": 0,
"text": "示例文本"
}
],
"appInfo": "CAQQiaO51AYY4Y+oq5SAgAMg56GIsQQ="
}
],
"conversationType": 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 <你的 App Token>',
'Content-Type: application/json',
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
响应示例
响应字段
| 字段 | 类型 | 说明 |
|---|---|---|
code | int64 | 统一封套状态码:0=成功,负数=失败 |
detail | string | 附加明细,通常为空 |
message | string | 文案:成功为 ok;失败形如 -码|描述 |
time | string | 服务端处理时间 YYYY-MM-DD HH:MM:SS |
常见错误
下表为企微错误码。业务失败时顶层 code=-1,具体错误码在 message 的 | 前,例如 -3004|参数错误;鉴权与网关错误见错误码。
| 错误码 | 含义 | 怎么办 |
|---|---|---|
-24001155 | 群发助手无法发送一年前的任务 | 检查任务 id |