返回提交历史
Modified
message/private_msg.md
+56
-54
XFEstudio/bilibili-API-collect
修改发送私信
608479a
代码差异
1 个文件
+56
-54
@@ -18,16 +18,16 @@
18
18
| ------- | ---- | -------- | --------------------------- |
19
19
| code | num | 返回值 | 0:成功<br />-6:账号未登录 |
20
20
| message | str | 错误信息 | 默认为ok |
21
| ttl | num | 1 | 作用尚不明确 |
21
| ttl | num | 1 | |
22
22
| data | obj | 信息本体 | |
23
23
24
24
`data` 对象:
25
25
26
| 字段 | 类型 | 内容 | 备注 |
27
| --------------- | ---- | -------------------- | ------------ |
28
| unfollow_unread | num | 未关注用户未读私信数 | |
29
| follow_unread | num | 已关注用户未读私信数 | |
30
| _gt_ | num | 0 | 作用尚不明确 |
26
| 字段 | 类型 | 内容 | 备注 |
27
| --------------- | ---- | -------------------- | ---- |
28
| unfollow_unread | num | 未关注用户未读私信数 | |
29
| follow_unread | num | 已关注用户未读私信数 | |
30
| _gt_ | num | 0 | |
31
31
32
32
**示例:**
33
33
@@ -51,9 +51,7 @@ curl 'http://api.vc.bilibili.com/session_svr/v1/session_svr/single_unread'\
51
51
}
52
52
```
53
53
54
55
56
## 发送私信
54
## 发送私信(web端)
57
55
58
56
> http://api.vc.bilibili.com/web_im/v1/web_im/send_msg
59
57
@@ -61,42 +59,48 @@ curl 'http://api.vc.bilibili.com/session_svr/v1/session_svr/single_unread'\
61
59
62
60
认证方式:Cookie(SESSDATA)
63
61
64
**正文参数(application/x-www-form-urlencoded)**
62
**正文参数(application/x-www-form-urlencoded):**
65
63
66
| 参数名 | 类型 | 内容 | 必要性 | 备注 |
67
| ------------------ | ---------- | --------- | ------ | -------------------------------------- |
68
| msg[sender_uid] | num | 发送者uid | 必要 | |
69
| msg[receiver_id] | num | 接收者uid | 必要 | |
70
| msg[receiver_type] | num | 1 | 必要 | |
71
| msg[msg_type] | num | | 必要 | 1:发送文字<br>2:发送图片<br>5:撤回消息 |
72
| msg[msg_status] | num | 0 | 非必要 | |
73
| msg[content] | obj \| num | 私信内容 | 必要 | 撤回消息时为num |
74
| csrf_token | str | | 必要 | 登录后的bili_jct |
64
| 参数名 | 类型 | 内容 | 必要性 | 备注 |
65
| ------------------ | ------------------------------------ | ------------------------ | ------ | -------------------------------------- |
66
| msg[sender_uid] | num | 发送者UID | 必要 | |
67
| msg[receiver_id] | num | 接收者UID | 必要 | |
68
| msg[receiver_type] | num | 1 | 必要 | 固定为1 |
69
| msg[msg_type] | num | 消息类型 | 必要 | 1:发送文字<br>2:发送图片<br>5:撤回消息 |
70
| msg[msg_status] | num | 0 | 非必要 | |
71
| msg[content] | 发送文字时:str<br />撤回消息时:num | 消息内容 | 必要 | **详见下表** |
72
| csrf_token | str | CSRF Token(位于cookie) | 必要 | |
75
73
76
`msg[content]`对象(发送文字):
74
`msg[content]`消息内容:
77
75
78
| 字段 | 类型 | 内容 | 备注 |
79
| ------- | ---- | -------- | ---- |
80
| content | str | 私信内容 | |
76
当发送文字时(`msg[msg_type]=1`):
81
77
78
该参数为json序列字串
82
79
80
根对象:
83
81
84
`msg[content]`对象(发送图片):
82
| 字段 | 类型 | 内容 | 备注 |
83
| ------- | ---- | -------- | ---- |
84
| content | str | 私信内容 | |
85
85
86
| 字段 | 类型 | 内容 | 必要性 | 备注 |
87
| -------- | ---- | ---------- | ------ | :--------------------------- |
88
| url | str | 图片的url | 必要 | 可以先上传第三方图床 |
89
| width | num | 图片的宽 | 非必要 | 单位:像素 |
90
| height | num | 图片的高 | 非必要 | 单位:像素 |
91
| type | str | 图片的类型 | 非必要 | 例如:jpeg |
92
| original | num | 1 | 非必要 | **作用未知** |
93
| size | num | 文件大小 | 非必要 | 单位:千字节<br>__向上取整__ |
86
当发送图片时(`msg[msg_type]=2`):
94
87
88
该参数为json序列字串
95
89
90
根对象:
96
91
97
<!--`msg[content]`撤回消息:msg_key-->
92
| 字段 | 类型 | 内容 | 备注 |
93
| -------- | ---- | -------- | :-------------------------------------------- |
94
| url | str | 图片url | 默认为B站相簿图片上传通道<br />也可用三方图床 |
95
| width | num | 图片的宽 | 单位:像素(非必要) |
96
| height | num | 图片的高 | 单位:像素(非必要) |
97
| type | str | 图片格式 | (非必要) |
98
| original | num | 1 | **作用未知**(非必要) |
99
| size | num | 文件大小 | 单位:千字节(非必要)<br>__向上取整__ |
98
100
101
当撤回消息时(`msg[msg_type]=5`):
99
102
103
该参数为数值,为目标消息的` msg_key `
100
104
101
105
**json回复:**
102
106
@@ -117,22 +121,21 @@ curl 'http://api.vc.bilibili.com/session_svr/v1/session_svr/single_unread'\
117
121
118
122
**示例:**
119
123
120
给B站用户`-1`发一条文字私信:
124
给目标用户`UID=1`发一条文字私信:
121
125
122
126
> up主你好,
123
127
>
124
> 催更
128
> 催更[doge]
125
129
126
130
```shell
127
正文参数:
128
msg[sender_uid] = 你的uid
129
msg[receiver_id] = -1
130
msg[receiver_type] = 1
131
msg[msg_type] = 1
132
msg[content] = {"content": "up主你好,\n催更[doge]"}
133
csrf_token = 登录后的bili_jct
134
cookies:
135
SESSDATA = 登录后的SESSDATA
131
curl 'http://api.vc.bilibili.com/web_im/v1/web_im/send_msg'\
132
--data-urlencode 'msg[sender_uid]=293793435'\
133
--data-urlencode 'msg[receiver_id]=1'\
134
--data-urlencode 'msg[receiver_type] =1'\
135
--data-urlencode 'msg[msg_type]=1'\
136
--data-urlencode 'msg[content]={"content":"up主你好,\n催更[doge]"}'\
137
--data-urlencode 'csrf_token=xxx'\
138
-b 'SESSDATA=xxx'
136
139
```
137
140
138
141
```json
@@ -147,20 +150,19 @@ cookies:
147
150
}
148
151
```
149
152
150
给B站用户`-1`发一条图片私信:
153
给目标用户`UID=1`发一条图片私信:
151
154
152
155
> <img src="https://i1.hdslb.com/bfs/face/aebb2639a0d47f2ce1fec0631f412eaf53d4a0be.jpg" style="zoom:50%;" >
153
156
154
157
```shell
155
正文参数:
156
msg[sender_uid] = 你的uid
157
msg[receiver_id] = -1
158
msg[receiver_type] = 1
159
msg[msg_type] = 2
160
msg[content] = {"url": "https://i1.hdslb.com/bfs/face/aebb2639a0d47f2ce1fec0631f412eaf53d4a0be.jpg"}
161
csrf_token = 登录后的bili_jct
162
cookies:
163
SESSDATA = 登录后的SESSDATA
158
curl 'http://api.vc.bilibili.com/web_im/v1/web_im/send_msg'\
159
--data-urlencode 'msg[sender_uid]=293793435'\
160
--data-urlencode 'msg[receiver_id]=1'\
161
--data-urlencode 'msg[receiver_type] =1'\
162
--data-urlencode 'msg[msg_type]=2'\
163
--data-urlencode 'msg[content]={"url":https://i1.hdslb.com/bfs/face/aebb2639a0d47f2ce1fec0631f412eaf53d4a0be.jpg}'\
164
--data-urlencode 'csrf_token=xxx'\
165
-b 'SESSDATA=xxx'
164
166
```
165
167
166
168
```json