2020-05-03 14:23:21 +08:00
|
|
|
|
# 弹幕操作
|
|
|
|
|
|
|
|
|
|
## 发送视频弹幕
|
|
|
|
|
|
|
|
|
|
> http://api.bilibili.com/x/v2/dm/post
|
|
|
|
|
|
2020-07-14 18:44:44 +08:00
|
|
|
|
*请求方式:POST*
|
2020-05-03 14:23:21 +08:00
|
|
|
|
|
2020-07-18 23:56:10 +08:00
|
|
|
|
认证方式:Cookie(SESSDATA)
|
2020-05-03 14:23:21 +08:00
|
|
|
|
|
2020-06-08 22:44:46 +08:00
|
|
|
|
**正文参数( application/x-www-form-urlencoded ):**
|
2020-05-03 14:23:21 +08:00
|
|
|
|
|
2020-07-09 16:34:50 +08:00
|
|
|
|
| 参数名 | 类型 | 内容 | 必要性 | 备注 |
|
|
|
|
|
| -------- | ---- | ------------------------ | ------------ | ------------------------------------------------------------ |
|
|
|
|
|
| type | num | 1 | 必要 | |
|
|
|
|
|
| oid | num | 视频CID | 必要 | |
|
|
|
|
|
| msg | str | 弹幕内容 | 必要 | 长度小于100字符 |
|
|
|
|
|
| bvid | str | 视频bvID | 必要(可选) | avID与bvID任选一个 |
|
|
|
|
|
| aid | num | 视频avID | 必要(可选) | avID与bvID任选一个 |
|
|
|
|
|
| progress | num | 弹幕出现在视频内的时间 | 非必要 | 单位为毫秒<br />默认为0 |
|
2020-07-23 00:08:20 +08:00
|
|
|
|
| color | num | 弹幕颜色设置 | 非必要 | 十进制RGB888值<br />默认为16777215(#FFFFFF)白色 |
|
|
|
|
|
| fontsize | num | 弹幕字号设置 | 非必要 | 默认为25 |
|
|
|
|
|
| pool | num | 弹幕池选择 | 非必要 | 0:普通池<br />1:字幕池<br />2:特殊池(代码/BAS弹幕)<br />默认为0 |
|
|
|
|
|
| mode | num | 弹幕类型选择 | 必要 | 1:普通弹幕<br />4:底部弹幕<br />5:顶部弹幕<br />7:高级弹幕<br />9:BAS弹幕(`pool`必须为2) |
|
2020-08-16 13:07:07 +08:00
|
|
|
|
| rnd | num | 当前时间戳*1000000 | 非必要 | **若无此项,则发送弹幕冷却时间限制为90s**<br />若有此项,则发送弹幕冷却时间限制为5s |
|
2020-07-09 16:34:50 +08:00
|
|
|
|
| csrf | str | CSRF Token(位于cookie) | 必要 | |
|
2020-05-03 14:23:21 +08:00
|
|
|
|
|
|
|
|
|
**json回复:**
|
|
|
|
|
|
|
|
|
|
根对象:
|
|
|
|
|
|
|
|
|
|
| 字段 | 类型 | 内容 | 备注 |
|
|
|
|
|
| ------- | ---- | -------- | ------------------------------------------------------------ |
|
2020-07-17 23:50:28 +08:00
|
|
|
|
| code | num | 返回值 | 0:成功<br />-101:账号未登录<br />-102:账号被封停<br />-111:csrf校验失败<br />-400:请求错误<br />-404:无此项<br />36700:系统升级中<br />36701:弹幕包含被禁止的内容<br />36702:弹幕长度大于100<br />36703:发送频率过快<br />36704:禁止向未审核的视频发送弹幕<br />36705:您的等级不足,不能发送弹幕<br />36706:您的等级不足,不能发送顶端弹幕<br />36707:您的等级不足,不能发送底端弹幕<br />36708:您的等级不足,不能发送彩色弹幕<br />36709:您的等级不足,不能发送高级弹幕<br />36710:您的权限不足,不能发送这种样式的弹幕<br />36711:该视频禁止发送弹幕<br />36712:level 1用户发送弹幕的最大长度为20<br />36713:稿件未付费<br />36714:弹幕发送时间不合法<br />36715:当日操作数量超过上限 |
|
2020-05-03 14:23:21 +08:00
|
|
|
|
| message | str | 错误信息 | 默认为0 |
|
2020-07-17 23:50:28 +08:00
|
|
|
|
| ttl | num | 1 | |
|
2020-05-03 14:23:21 +08:00
|
|
|
|
| data | obj | 信息本体 | |
|
|
|
|
|
|
|
|
|
|
`data`对象:
|
|
|
|
|
|
2020-06-16 23:09:49 +08:00
|
|
|
|
| 字段 | 类型 | 内容 | 备注 |
|
|
|
|
|
| -------- | ---- | -------- | ------------ |
|
|
|
|
|
| action | str | 空 | 作用尚不明确 |
|
|
|
|
|
| dmid | num | 弹幕dmID | |
|
|
|
|
|
| dmid_str | str | 弹幕dmID | 字串形式 |
|
|
|
|
|
| visible | bool | true | 作用尚不明确 |
|
2020-05-03 14:23:21 +08:00
|
|
|
|
|
|
|
|
|
**示例:**
|
|
|
|
|
|
|
|
|
|
为视频`av2`/`BV1xx411c7mD`(CID为`62131`)的5s位置发送一条弹幕`前来考古`(颜色为#FFFFFF,字号25,普通弹幕,游动弹幕)
|
|
|
|
|
|
2020-07-18 23:56:10 +08:00
|
|
|
|
```shell
|
|
|
|
|
curl 'http://api.bilibili.com/x/v2/dm/post'\
|
|
|
|
|
--data-urlencode 'type=1'\
|
|
|
|
|
--data-urlencode 'oid=62131'\
|
|
|
|
|
--data-urlencode 'msg=前来考古'\
|
|
|
|
|
--data-urlencode 'aid=2'\
|
|
|
|
|
--data-urlencode 'progress=5000'\
|
|
|
|
|
--data-urlencode 'color=16777215'\
|
|
|
|
|
--data-urlencode 'fontsize=25'\
|
|
|
|
|
--data-urlencode 'pool=0'\
|
|
|
|
|
--data-urlencode 'mode=1'\
|
|
|
|
|
--data-urlencode 'rnd=3456789987654321'\
|
|
|
|
|
--data-urlencode 'csrf=xxx'\
|
|
|
|
|
-b 'SESSDATA=xxx'
|
|
|
|
|
```
|
2020-05-03 14:23:21 +08:00
|
|
|
|
|
2020-08-31 16:37:38 +08:00
|
|
|
|
<details>
|
|
|
|
|
<summary>查看响应示例:</summary>
|
|
|
|
|
|
2020-05-03 14:23:21 +08:00
|
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"code":0,
|
|
|
|
|
"message":"0",
|
|
|
|
|
"ttl":1,
|
|
|
|
|
"data":{
|
|
|
|
|
"action":"",
|
|
|
|
|
"dmid":32161968826613767,
|
|
|
|
|
"dmid_str":"32161968826613767",
|
|
|
|
|
"visible":true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2020-08-31 16:37:38 +08:00
|
|
|
|
</details>
|
|
|
|
|
|
2020-05-07 18:33:01 +08:00
|
|
|
|
## 撤回弹幕
|
|
|
|
|
|
|
|
|
|
> http://api.bilibili.com/x/dm/recall
|
|
|
|
|
|
2020-07-14 18:44:44 +08:00
|
|
|
|
*请求方式:POST*
|
2020-05-07 18:33:01 +08:00
|
|
|
|
|
2020-07-18 23:56:10 +08:00
|
|
|
|
认证方式:Cookie(SESSDATA)
|
2020-05-07 18:33:01 +08:00
|
|
|
|
|
2020-07-18 23:56:10 +08:00
|
|
|
|
仅能撤回自己两分钟内的弹幕,且每天只有3次机会
|
2020-05-07 18:33:01 +08:00
|
|
|
|
|
2020-06-08 22:44:46 +08:00
|
|
|
|
**正文参数( application/x-www-form-urlencoded ):**
|
2020-05-07 18:33:01 +08:00
|
|
|
|
|
2020-07-09 16:34:50 +08:00
|
|
|
|
| 参数名 | 类型 | 内容 | 必要性 | 备注 |
|
|
|
|
|
| ------ | ---- | ------------------------ | ------ | ---- |
|
|
|
|
|
| dmid | num | 弹幕dmID | 必要 | |
|
|
|
|
|
| cid | num | 视频CID | 必要 | |
|
|
|
|
|
| csrf | str | CSRF Token(位于cookie) | 必要 | |
|
2020-05-07 18:33:01 +08:00
|
|
|
|
|
|
|
|
|
**json回复:**
|
|
|
|
|
|
|
|
|
|
根对象:
|
|
|
|
|
|
|
|
|
|
| 字段 | 类型 | 内容 | 备注 |
|
|
|
|
|
| ------- | ---- | -------- | ------------------------------------------------------------ |
|
2020-07-17 23:50:28 +08:00
|
|
|
|
| code | num | 返回值 | 0:成功<br />-101:账号未登录<br />-102:账号被封停<br />-111:csrf校验失败<br />-400:请求错误<br />-404:无此项<br />36301:撤回失败,弹幕发送已过2分钟<br />36302:撤回失败,弹幕已经被删除或撤回<br />36303:撤回失败,今天撤回的机会已经用完<br />36304:撤回失败,服务器出错 |
|
2020-05-07 18:33:01 +08:00
|
|
|
|
| message | str | 错误信息 | 成功后显示剩余次数 |
|
2020-07-17 23:50:28 +08:00
|
|
|
|
| ttl | num | 1 | |
|
2020-05-07 18:33:01 +08:00
|
|
|
|
|
|
|
|
|
**示例:**
|
|
|
|
|
|
2020-07-18 23:56:10 +08:00
|
|
|
|
撤回`CID=168901231`下的弹幕`32310301474947077`的弹幕
|
2020-05-07 18:33:01 +08:00
|
|
|
|
|
2020-07-18 23:56:10 +08:00
|
|
|
|
```shell
|
|
|
|
|
curl 'http://api.bilibili.com/x/dm/recall'\
|
|
|
|
|
--data-urlencode 'cid=168901231'\
|
|
|
|
|
--data-urlencode 'dmid=32310301474947077'\
|
|
|
|
|
--data-urlencode 'csrf=xxx'\
|
|
|
|
|
-b 'SESSDATA=xxx'
|
|
|
|
|
```
|
2020-05-07 18:33:01 +08:00
|
|
|
|
|
2020-08-31 16:37:38 +08:00
|
|
|
|
<details>
|
|
|
|
|
<summary>查看响应示例:</summary>
|
|
|
|
|
|
2020-05-07 18:33:01 +08:00
|
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"code": 0,
|
|
|
|
|
"message": "撤回成功,你还有3次撤回机会"
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2020-08-31 16:37:38 +08:00
|
|
|
|
</details>
|
|
|
|
|
|
2020-05-10 18:25:23 +08:00
|
|
|
|
## 购买高级弹幕发送权限
|
|
|
|
|
|
|
|
|
|
> http://api.bilibili.com/x/dm/adv/buy
|
|
|
|
|
|
2020-07-14 18:44:44 +08:00
|
|
|
|
*请求方式:POST*
|
2020-05-10 18:25:23 +08:00
|
|
|
|
|
2020-07-18 23:56:10 +08:00
|
|
|
|
认证方式:Cookie(SESSDATA)
|
2020-05-10 18:25:23 +08:00
|
|
|
|
|
|
|
|
|
购买一次需要2硬币,同时向up主发送请求
|
|
|
|
|
|
2020-06-08 22:44:46 +08:00
|
|
|
|
**正文参数( application/x-www-form-urlencoded ):**
|
2020-05-10 18:25:23 +08:00
|
|
|
|
|
2020-07-09 16:34:50 +08:00
|
|
|
|
| 参数名 | 类型 | 内容 | 必要性 | 备注 |
|
|
|
|
|
| ------ | ---- | ------------------------ | ------ | ---- |
|
|
|
|
|
| mode | str | sp | 必要 | |
|
|
|
|
|
| cid | num | 视频CID | 必要 | |
|
|
|
|
|
| csrf | str | CSRF Token(位于cookie) | 必要 | |
|
2020-05-10 18:25:23 +08:00
|
|
|
|
|
|
|
|
|
**json回复:**
|
|
|
|
|
|
|
|
|
|
根对象:
|
|
|
|
|
|
|
|
|
|
| 字段 | 类型 | 内容 | 备注 |
|
|
|
|
|
| ------- | ---- | -------- | ------------------------------------------------------------ |
|
2020-07-17 23:50:28 +08:00
|
|
|
|
| code | num | 返回值 | 0:成功<br />-101:账号未登录<br />-102:账号被封停<br />-111:csrf校验失败<br />-107:硬币不足<br />-400:请求错误<br />36007:不允许购买<br />36009:正在确认中<br />36010:已购买 |
|
2020-05-10 18:25:23 +08:00
|
|
|
|
| message | str | 返回信息 | |
|
2020-07-17 23:50:28 +08:00
|
|
|
|
| ttl | num | 1 | |
|
2020-05-10 18:25:23 +08:00
|
|
|
|
|
|
|
|
|
示例:
|
|
|
|
|
|
|
|
|
|
购买视频CID为`168901231`的高级弹幕发送权限
|
|
|
|
|
|
2020-07-18 23:56:10 +08:00
|
|
|
|
```shell
|
|
|
|
|
curl 'http://api.bilibili.com/x/dm/adv/buy'\
|
|
|
|
|
--data-urlencode 'cid=168901231'\
|
|
|
|
|
--data-urlencode 'mode=sp'\
|
|
|
|
|
--data-urlencode 'csrf=xxx'\
|
|
|
|
|
-b 'SESSDATA=xxx'
|
|
|
|
|
```
|
2020-05-10 18:25:23 +08:00
|
|
|
|
|
2020-08-31 16:37:38 +08:00
|
|
|
|
<details>
|
|
|
|
|
<summary>查看响应示例:</summary>
|
|
|
|
|
|
2020-05-10 18:25:23 +08:00
|
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"code":0,
|
|
|
|
|
"message":"已成功购买"
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2020-08-31 16:37:38 +08:00
|
|
|
|
</details>
|
|
|
|
|
|
2020-05-10 18:25:23 +08:00
|
|
|
|
## 检测高级弹幕发送权限
|
2020-05-09 20:57:11 +08:00
|
|
|
|
|
|
|
|
|
> http://api.bilibili.com/x/dm/adv/state
|
|
|
|
|
|
2020-07-14 18:44:44 +08:00
|
|
|
|
*请求方式:GET*
|
2020-05-09 20:57:11 +08:00
|
|
|
|
|
2020-07-18 23:56:10 +08:00
|
|
|
|
认证方式:Cookie(SESSDATA)
|
2020-05-09 20:57:11 +08:00
|
|
|
|
|
2020-06-08 22:44:46 +08:00
|
|
|
|
**url参数:**
|
2020-05-09 20:57:11 +08:00
|
|
|
|
|
|
|
|
|
| 参数名 | 类型 | 内容 | 必要性 | 备注 |
|
|
|
|
|
| ------ | ---- | ------- | ------ | ---- |
|
2020-06-08 22:44:46 +08:00
|
|
|
|
| mode | str | sp | 必要 | |
|
|
|
|
|
| cid | num | 视频CID | 必要 | |
|
2020-05-09 20:57:11 +08:00
|
|
|
|
|
|
|
|
|
**json回复:**
|
|
|
|
|
|
|
|
|
|
根对象:
|
|
|
|
|
|
2020-05-10 18:25:23 +08:00
|
|
|
|
| 字段 | 类型 | 内容 | 备注 |
|
|
|
|
|
| ------- | ----------------------------- | ---------------- | -------------------------------------------------- |
|
|
|
|
|
| code | num | 返回值 | 0:成功<br />-101:账号未登录<br />--400:请求错误 |
|
|
|
|
|
| message | str | 错误信息 | 默认为0 |
|
2020-07-17 23:50:28 +08:00
|
|
|
|
| ttl | num | 1 | |
|
2020-05-10 18:25:23 +08:00
|
|
|
|
| data | 有效时:obj<br />无效时:null | 有效时:信息本体 | |
|
2020-05-09 20:57:11 +08:00
|
|
|
|
|
|
|
|
|
`data`对象:
|
|
|
|
|
|
|
|
|
|
| 字段 | 类型 | 内容 | 备注 |
|
|
|
|
|
| ------- | ---- | ---------------- | ------------------------------------------ |
|
|
|
|
|
| coins | num | 需要支付的硬币数 | |
|
|
|
|
|
| confirm | num | 是否同意 | 1:同意<br />2:未同意<br />未购买时无此项 |
|
2020-07-17 23:50:28 +08:00
|
|
|
|
| accept | bool | 是否允许申请 | true:允许<br />false:不允许 |
|
2020-05-09 20:57:11 +08:00
|
|
|
|
| hasBuy | bool | 是否已购买 | true:已购买<br />未购买时无此项 |
|
|
|
|
|
|
|
|
|
|
**示例:**
|
|
|
|
|
|
|
|
|
|
查询视频CID为`168901231`的视频高级弹幕权限购买状态
|
|
|
|
|
|
|
|
|
|
当前状态为已购买且同意
|
|
|
|
|
|
2020-07-18 23:56:10 +08:00
|
|
|
|
```shell
|
|
|
|
|
curl -G 'http://api.bilibili.com/x/dm/adv/state'\
|
|
|
|
|
--data-urlencode 'cid=168901231'\
|
|
|
|
|
--data-urlencode 'mode=sp'\
|
|
|
|
|
-b 'SESSDATA=xxx'
|
|
|
|
|
```
|
2020-05-09 20:57:11 +08:00
|
|
|
|
|
2020-08-31 16:37:38 +08:00
|
|
|
|
<details>
|
|
|
|
|
<summary>查看响应示例:</summary>
|
|
|
|
|
|
2020-05-09 20:57:11 +08:00
|
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"code": 0,
|
|
|
|
|
"message": "0",
|
|
|
|
|
"ttl": 1,
|
|
|
|
|
"data": {
|
|
|
|
|
"coins": 2,
|
|
|
|
|
"confirm": 1,
|
|
|
|
|
"accept": true,
|
|
|
|
|
"hasBuy": true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2020-08-31 16:37:38 +08:00
|
|
|
|
</details>
|