Appearance
群发助手-群发
向一批客户或客户群批量发送消息。
说明与注意
- 立即发送,返回
data.msgId;发出的记录直接出现在getGroupSendRecord(id == msgId),不进getPendingGroupSendList队列 ——getPendingGroupSendList/groupSendPending是另一套独立机制,不是本接口的后续。实测用一次性自建空群做 receiver 验证(customerGroup=true)。 - 发送频率与限制与企微官方群发规则一致。
请求参数
| 参数 | 必填 | 类型 | 说明 |
|---|---|---|---|
appid | 是 | string | 实例 appid,标识操作哪个已登录账号。示例:we_xxxxxxxxxxxxxxx |
customerGroup | 是 | boolean | true=群发到客户群(receiverList 只能是群 id);false=群发到客户(receiverList 只能是客户 id),二者不能混。示例:true |
contentList | 条件必填 | array<object> | 群发内容列表;materialId 为 0(不是素材库内容)时必填。示例:[{"contentType":0,"content":[{"type":3,"text":"[撇嘴]"},{"t… |
receiverList | 是 | array<int64> | 接收者 id 列表。示例:[10710637461658379] |
materialId | 是 | int64 | 素材库 id;不是素材库内容时传 0。示例:117159486110430465 |
contentList[] 字段
| 字段 | 类型 | 说明 |
|---|---|---|
contentList[].contentType | int64 | 消息类型码(0 文本/14 图片/23 视频…) |
contentList[].content | array<object> | 消息内容;文本为数组、媒体为对象 |
contentList[].content[].type | int64 | 类型编码(具体含义随所在对象:成员/部门、图片/视频、节点类型等,详见对应接口) |
contentList[].content[].text | string | type 0/3 的文本内容 |
请求示例
http
POST {BASE_URL}/wx-api/api/message/groupSend
Authorization: Bearer <你的 App Token>
Content-Type: application/json
{
"appid": "we_xxxxxxxxxxxxxxx",
"customerGroup": true,
"contentList": [
{
"contentType": 0,
"content": [
{
"type": 3,
"text": "[撇嘴]"
},
{
"type": 0,
"text": "企业"
}
]
},
{
"contentType": 14,
"content": {
"id": "<uploadImage fileId>",
"size": 570260,
"width": 828,
"height": 1792,
"aesKey": "9cf6...",
"md5": "f6e0..."
}
},
{
"contentType": 22,
"content": {
"id": "*1*<大文件 id>",
"size": 285357,
"duration": 2,
"width": 1280,
"height": 720,
"thumbUrl": "https://wework.qpic.cn/...",
"md5": "9915..."
}
},
{
"contentType": 20,
"content": {}
}
],
"receiverList": [
10710637461658379
],
"materialId": 117159486110430465
}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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
bash
curl -X POST '{BASE_URL}/wx-api/api/message/groupSend' \
-H 'Authorization: Bearer <你的 App Token>' \
-H 'Content-Type: application/json' \
--data-raw '{
"appid": "we_xxxxxxxxxxxxxxx",
"customerGroup": true,
"contentList": [
{
"contentType": 0,
"content": [
{
"type": 3,
"text": "[撇嘴]"
},
{
"type": 0,
"text": "企业"
}
]
},
{
"contentType": 14,
"content": {
"id": "<uploadImage fileId>",
"size": 570260,
"width": 828,
"height": 1792,
"aesKey": "9cf6...",
"md5": "f6e0..."
}
},
{
"contentType": 22,
"content": {
"id": "*1*<大文件 id>",
"size": 285357,
"duration": 2,
"width": 1280,
"height": 720,
"thumbUrl": "https://wework.qpic.cn/...",
"md5": "9915..."
}
},
{
"contentType": 20,
"content": {}
}
],
"receiverList": [
10710637461658379
],
"materialId": 117159486110430465
}'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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
python
import requests
url = "{BASE_URL}/wx-api/api/message/groupSend"
headers = {"Authorization": "Bearer <你的 App Token>", "Content-Type": "application/json"}
body = """{
"appid": "we_xxxxxxxxxxxxxxx",
"customerGroup": true,
"contentList": [
{
"contentType": 0,
"content": [
{
"type": 3,
"text": "[撇嘴]"
},
{
"type": 0,
"text": "企业"
}
]
},
{
"contentType": 14,
"content": {
"id": "<uploadImage fileId>",
"size": 570260,
"width": 828,
"height": 1792,
"aesKey": "9cf6...",
"md5": "f6e0..."
}
},
{
"contentType": 22,
"content": {
"id": "*1*<大文件 id>",
"size": 285357,
"duration": 2,
"width": 1280,
"height": 720,
"thumbUrl": "https://wework.qpic.cn/...",
"md5": "9915..."
}
},
{
"contentType": 20,
"content": {}
}
],
"receiverList": [
10710637461658379
],
"materialId": 117159486110430465
}"""
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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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/groupSend";
String body = "{\n" +
" \"appid\": \"we_xxxxxxxxxxxxxxx\",\n" +
" \"customerGroup\": true,\n" +
" \"contentList\": [\n" +
" {\n" +
" \"contentType\": 0,\n" +
" \"content\": [\n" +
" {\n" +
" \"type\": 3,\n" +
" \"text\": \"[撇嘴]\"\n" +
" },\n" +
" {\n" +
" \"type\": 0,\n" +
" \"text\": \"企业\"\n" +
" }\n" +
" ]\n" +
" },\n" +
" {\n" +
" \"contentType\": 14,\n" +
" \"content\": {\n" +
" \"id\": \"<uploadImage fileId>\",\n" +
" \"size\": 570260,\n" +
" \"width\": 828,\n" +
" \"height\": 1792,\n" +
" \"aesKey\": \"9cf6...\",\n" +
" \"md5\": \"f6e0...\"\n" +
" }\n" +
" },\n" +
" {\n" +
" \"contentType\": 22,\n" +
" \"content\": {\n" +
" \"id\": \"*1*<大文件 id>\",\n" +
" \"size\": 285357,\n" +
" \"duration\": 2,\n" +
" \"width\": 1280,\n" +
" \"height\": 720,\n" +
" \"thumbUrl\": \"https://wework.qpic.cn/...\",\n" +
" \"md5\": \"9915...\"\n" +
" }\n" +
" },\n" +
" {\n" +
" \"contentType\": 20,\n" +
" \"content\": {}\n" +
" }\n" +
" ],\n" +
" \"receiverList\": [\n" +
" 10710637461658379\n" +
" ],\n" +
" \"materialId\": 117159486110430465\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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
php
<?php
$url = '{BASE_URL}/wx-api/api/message/groupSend';
$body = <<<'JSON'
{
"appid": "we_xxxxxxxxxxxxxxx",
"customerGroup": true,
"contentList": [
{
"contentType": 0,
"content": [
{
"type": 3,
"text": "[撇嘴]"
},
{
"type": 0,
"text": "企业"
}
]
},
{
"contentType": 14,
"content": {
"id": "<uploadImage fileId>",
"size": 570260,
"width": 828,
"height": 1792,
"aesKey": "9cf6...",
"md5": "f6e0..."
}
},
{
"contentType": 22,
"content": {
"id": "*1*<大文件 id>",
"size": 285357,
"duration": 2,
"width": 1280,
"height": 720,
"thumbUrl": "https://wework.qpic.cn/...",
"md5": "9915..."
}
},
{
"contentType": 20,
"content": {}
}
],
"receiverList": [
10710637461658379
],
"materialId": 117159486110430465
}
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
响应示例
json
{
"code": 0,
"data": {
"msgId": 117252339567559381
},
"detail": "",
"message": "ok",
"time": "2026-09-11 20:20:00"
}1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
响应字段
| 字段 | 类型 | 说明 |
|---|---|---|
code | int64 | 统一封套状态码:0=成功,负数=失败 |
data | object | 业务数据 |
data.msgId | int64 | 下一页起始 msgId |
detail | string | 附加明细,通常为空 |
message | string | 文案:成功为 ok;失败形如 -码|描述 |
time | string | 服务端处理时间 YYYY-MM-DD HH:MM:SS |