curl -X POST "http://localhost:5001/channel/subscriber_add" \
-H "Content-Type: application/json" \
-d '{
"channel_id": "group123",
"channel_type": 2,
"subscribers": ["user4", "user5", "user6"],
"reset": 0,
"temp_subscriber": 0
}'
const response = await fetch('http://localhost:5001/channel/subscriber_add', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
channel_id: 'group123',
channel_type: 2,
subscribers: ['user4', 'user5', 'user6'],
reset: 0,
temp_subscriber: 0
})
});
const data = await response.json();
console.log(data);
import requests
data = {
"channel_id": "group123",
"channel_type": 2,
"subscribers": ["user4", "user5", "user6"],
"reset": 0,
"temp_subscriber": 0
}
response = requests.post('http://localhost:5001/channel/subscriber_add', json=data)
result = response.json()
print(result)
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
data := map[string]interface{}{
"channel_id": "group123",
"channel_type": 2,
"subscribers": []string{"user4", "user5", "user6"},
"reset": 0,
"temp_subscriber": 0,
}
jsonData, _ := json.Marshal(data)
resp, err := http.Post(
"http://localhost:5001/channel/subscriber_add",
"application/json",
bytes.NewBuffer(jsonData),
)
if err != nil {
panic(err)
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Printf("%+v\n", result)
}
{
"status": "ok"
}
频道管理
添加频道订阅者
向频道添加订阅者(成员)
POST
/
channel
/
subscriber_add
curl -X POST "http://localhost:5001/channel/subscriber_add" \
-H "Content-Type: application/json" \
-d '{
"channel_id": "group123",
"channel_type": 2,
"subscribers": ["user4", "user5", "user6"],
"reset": 0,
"temp_subscriber": 0
}'
const response = await fetch('http://localhost:5001/channel/subscriber_add', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
channel_id: 'group123',
channel_type: 2,
subscribers: ['user4', 'user5', 'user6'],
reset: 0,
temp_subscriber: 0
})
});
const data = await response.json();
console.log(data);
import requests
data = {
"channel_id": "group123",
"channel_type": 2,
"subscribers": ["user4", "user5", "user6"],
"reset": 0,
"temp_subscriber": 0
}
response = requests.post('http://localhost:5001/channel/subscriber_add', json=data)
result = response.json()
print(result)
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
data := map[string]interface{}{
"channel_id": "group123",
"channel_type": 2,
"subscribers": []string{"user4", "user5", "user6"},
"reset": 0,
"temp_subscriber": 0,
}
jsonData, _ := json.Marshal(data)
resp, err := http.Post(
"http://localhost:5001/channel/subscriber_add",
"application/json",
bytes.NewBuffer(jsonData),
)
if err != nil {
panic(err)
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Printf("%+v\n", result)
}
{
"status": "ok"
}
概述
向频道添加订阅者(成员),支持批量添加和重置模式。请求体
必传参数
频道 ID
频道类型
1- 个人频道2- 群组频道
可选参数
是否重置现有订阅者
0- 不重置,追加新订阅者1- 重置,替换所有现有订阅者
是否为临时订阅者
0- 永久订阅者1- 临时订阅者
curl -X POST "http://localhost:5001/channel/subscriber_add" \
-H "Content-Type: application/json" \
-d '{
"channel_id": "group123",
"channel_type": 2,
"subscribers": ["user4", "user5", "user6"],
"reset": 0,
"temp_subscriber": 0
}'
const response = await fetch('http://localhost:5001/channel/subscriber_add', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
channel_id: 'group123',
channel_type: 2,
subscribers: ['user4', 'user5', 'user6'],
reset: 0,
temp_subscriber: 0
})
});
const data = await response.json();
console.log(data);
import requests
data = {
"channel_id": "group123",
"channel_type": 2,
"subscribers": ["user4", "user5", "user6"],
"reset": 0,
"temp_subscriber": 0
}
response = requests.post('http://localhost:5001/channel/subscriber_add', json=data)
result = response.json()
print(result)
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
data := map[string]interface{}{
"channel_id": "group123",
"channel_type": 2,
"subscribers": []string{"user4", "user5", "user6"},
"reset": 0,
"temp_subscriber": 0,
}
jsonData, _ := json.Marshal(data)
resp, err := http.Post(
"http://localhost:5001/channel/subscriber_add",
"application/json",
bytes.NewBuffer(jsonData),
)
if err != nil {
panic(err)
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Printf("%+v\n", result)
}
{
"status": "ok"
}
响应字段
操作状态,成功时返回
"ok"状态码
| 状态码 | 说明 |
|---|---|
| 200 | 订阅者添加成功 |
| 400 | 请求参数错误 |
| 403 | 没有操作权限 |
| 404 | 频道不存在 |
| 500 | 服务器内部错误 |
参数说明
重置模式 (reset)
| 值 | 模式 | 说明 | 使用场景 |
|---|---|---|---|
| 0 | 追加模式 | 在现有成员基础上添加新成员 | 邀请新成员加入 |
| 1 | 重置模式 | 清空现有成员,设置为新的成员列表 | 重新组建群组 |
临时订阅者 (temp_subscriber)
| 值 | 类型 | 特点 | 适用场景 |
|---|---|---|---|
| 0 | 永久订阅者 | 持久的成员关系 | 正式群组成员 |
| 1 | 临时订阅者 | 临时的成员关系 | 临时访客、会议参与者 |
使用场景
群组管理
- 邀请新成员:群主或管理员邀请新用户加入群组
- 批量导入:从其他平台批量导入成员列表
- 重建群组:使用重置模式重新组建群组成员
⌘I

