From 7c2c6e31364da72f5e4790a1453861efc10489f0 Mon Sep 17 00:00:00 2001 From: SocialSisterYi <45892418+SocialSisterYi@users.noreply.github.com> Date: Wed, 4 Mar 2020 18:55:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=8C=E7=BB=B4=E7=A0=81?= =?UTF-8?q?=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +- README.md | 3 +- login/QR.md | 121 +++++++++++++++++++++++++++++++++++++ user/status_number.md | 13 ++-- video/status_number.md | 134 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 266 insertions(+), 8 deletions(-) create mode 100644 login/QR.md create mode 100644 video/status_number.md diff --git a/.gitignore b/.gitignore index ddfcc03..9caa402 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ -login/QR.md user/relation.md user/space.md login/password&SMS.md B站API.txt +video/info.md +video/snapshot.md diff --git a/README.md b/README.md index a96172c..141428d 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,8 @@ - 动态 - 历史&稍后再看 - 直播 -- 登录 +- [登录](https://github.com/SocialSisterYi/bilibili-API-collect/tree/master/login) + - [二维码登录](https://github.com/SocialSisterYi/bilibili-API-collect/tree/master/login/QR.md)√ - [用户](https://github.com/SocialSisterYi/bilibili-API-collect/tree/master/user) - [基本信息](https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/user/info.md)√ - [状态数](https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/user/status_number.md)√ diff --git a/login/QR.md b/login/QR.md new file mode 100644 index 0000000..cf5532e --- /dev/null +++ b/login/QR.md @@ -0,0 +1,121 @@ +# 二维码登录 + +流程&逻辑: + +1. 获取「二维码url」以及「秘钥」,以「二维码url」作为内容生成二维码,等待手机端扫描 +2. 以「秘钥」作为参数进行POST +3. if "code"==true goto 6 else goto 4(是否已经确认) +4. if "data"==-4 goto 2 else goto 5(是否已经扫描) +5. if "data"==-5 goto 3 && 提示「已扫描」 else goto 1&提示二维码超时或错误(秘钥是否有效) +6. + +## 获取二维码内容url以及秘钥 (秘钥超时为180秒) +passport.bilibili.com/qrcode/getLoginUrl + +*方式:GET* + + +**json回复** +| 字段 | 类型 | 内容 | 备注 | +| ------- | ----- | --------- | ------------------ | +| code | num | 返回值 | 0成功 | +| status | bool | true | 作用尚不明确 | +| ts | num | 请求时间 | 时间戳 | +| data | obj | 信息本体 | | + +data 对象: +| 字段 | 类型 | 内容 | 备注 | +| -------- | ----- | ------------- | ---------- | +| url | str | 二维码内容url | 恒为87字符 | +| oauthKey | str | 扫码登录秘钥 | 恒为32字符 | + +示例: + +http://passport.bilibili.com/qrcode/getLoginUrl +``` +{ + "code": 0, + "status": true, + "ts": 1583314311, + "data": { + "url": "https://passport.bilibili.com/qrcode/h5/login?oauthKey=c3bd5286a2b40a822f5f60e9bf3f602e", + "oauthKey": "c3bd5286a2b40a822f5f60e9bf3f602e" + } +} +``` + +## 验证二维码登录 +passport.bilibili.com/qrcode/getLoginInfo + +正确时会进行设置以下cookie项: +DedeUserID DedeUserID__ckMd5 SESSDATA bili_jct + + +*方式:POST* + +参数: +| 参数名 | 内容 | 必要性 | 备注 | +| ---------| ------------ | ------ |------------------------------ | +| oauthKey | 扫码登录秘钥 | 必要 | | +| gourl | 跳转url | 非必要 | 默认为http://www.bilibili.com | + + +**json回复** +| 字段 | 类型 | 内容 | 备注 | +| ------- | ------------------- | ------------------------------------ | ----------------------------------------------- | +| status | bool | 扫码是否成功 | | +| code | num | 返回值 | 0成功 | +| message | str | 错误信息 | 正确无 | +| ts | num | 扫码时间 | 错误无 | +| data | 正确时obj 错误时num | 正确时:游戏分站url 错误时:错误代码 | 错误时:-1秘钥错误 -2秘钥超时 -4未扫描 -5未确认 | + +data 对象: +| 字段 | 类型 | 内容 | 备注 | +| ---- | ---- | --------------- | ---- | +| url | str | 游戏分站登录url | | + +示例: + +curl -d "oauthKey=xxx" "http://passport.bilibili.com/qrcode/getLoginInfo" +``` +{ + "code": 0, + "status": true, + "ts": 1583315474, + "data": { + "url": "https://passport.biligame.com/crossDomain?DedeUserID=293793435&DedeUserID__ckMd5=ab24cb40578a85b0&Expires=15551000&SESSDATA=7816ef30%2C1598867474%2C500ce%2A31&bili_jct=cf13274801a8ff69bdbc4a1c0f09688a&gourl=http%3A%2F%2Fwww.bilibili.com" + } +} +``` + +抓包信息(回复头部): + +可明显看见设置了几个cookie(本人手打cookie,成功登录B站)(重要token已河蟹处理) + +``` +HTTP/1.1 200 OK +Date: Wed, 04 Mar 2020 10:36:37 GMT +Content-Type: application/json;charset=UTF-8 +Transfer-Encoding: chunked +Connection: keep-alive +Server: Apache-Coyote/1.1 +Set-Cookie: sid=***; Domain=.bilibili.com; Expires=Thu, 04-Mar-2021 10:36:37 GMT; Path=/ +Set-Cookie: DedeUserID=***; Domain=.bilibili.com; Expires=Mon, 31-Aug-2020 10:19:57 GMT; Path=/ +Set-Cookie: DedeUserID__ckMd5=***; Domain=.bilibili.com; Expires=Mon, 31-Aug-2020 10:19:57 GMT; Path=/ +Set-Cookie: SESSDATA=***; Domain=.bilibili.com; Expires=Mon, 31-Aug-2020 10:19:57 GMT; Path=/; HttpOnly +Set-Cookie: bili_jct=***; Domain=.bilibili.com; Expires=Mon, 31-Aug-2020 10:19:57 GMT; Path=/ +Expires: Wed, 04 Mar 2020 10:36:36 GMT +Cache-Control: no-cache +X-Cache-Webcdn: BYPASS from ks-sxhz-dx-w-01 +``` + +**游戏分站登录url** +https://passport.biligame.com/crossDomain? +DedeUserID=(登录UID)& +DedeUserID__ckMd5=(DedeUserID__ckMd5)& +Expires=(过期时间 秒)& +SESSDATA=(SESSDATA)& +bili_jct=(bili_jct)& +gourl=(跳转网址 默认为主页) + + diff --git a/user/status_number.md b/user/status_number.md index da0bb78..db05de0 100644 --- a/user/status_number.md +++ b/user/status_number.md @@ -1,4 +1,4 @@ -# 状态数 +# 用户状态数 ## 关系状态数 api.bilibili.com/x/relation/stat @@ -69,7 +69,7 @@ data 对象: | ------- | ----- | ---------- | ----- | | archive | obj | 视频播放量 | | | article | obj | 专栏阅读量 | | -| likes | num | 被赞次数 | | +| likes | num | 获赞次数 | | archive 对象: | 字段 | 类型 | 内容 | 备注 | @@ -142,10 +142,11 @@ channel 对象: | guest | num | 频道数 | | favourite 对象: -| 字段 | 类型 | 内容 | 备注 | -| ------- | ----- | ---------- | ------------ | -| master | num | 收藏夹数 | 无视隐私设置 | -| guest | num | 收藏夹数 | 无视隐私设置 | +| 字段 | 类型 | 内容 | 备注 | +| ------- | ----- | -------------- | ----------------------- | +| master | num | 全部收藏夹数 | 需要登录 只能查看自己的 | +| guest | num | 公开收藏夹数 | 无视隐私设置 | + 示例: diff --git a/video/status_number.md b/video/status_number.md new file mode 100644 index 0000000..bb5c2d2 --- /dev/null +++ b/video/status_number.md @@ -0,0 +1,134 @@ +# 视频状态数 + +##视频状态数1 +api.bilibili.com/archive_stat/stat + +*方式:GET* + +参数: +| 参数名 | 内容 | 必要性 | 备注 | +| -------| -------- | ------ |------| +| aid | 视频avID | 必要 | | + + +**json回复** +| 字段 | 类型 | 内容 | 备注 | +| ------- | ----- | --------- | -------------------------------- | +| code | num | 返回值 | 0成功 40001请求错误 40003无视频 | +| message | str | 错误信息 | 默认为0 | +| ttl | num | 1 | 作用尚不明确 | +| data | obj | 信息本体 | | + +data 对象: +| 字段 | 类型 | 内容 | 备注 | +| ---------- | ----------------- | ------------------------------- | ---------------- | +| aid | num | 视频avID | | +| view | 普通num 屏蔽时str | 普通:观看次数 屏蔽时:"--" | | +| danmaku | num | 弹幕条数 | | +| reply | num | 评论条数 | | +| favorite | num | 收藏人数 | | +| coin | num | 投币枚数 | | +| share | num | 分享次数 | | +| now_rank | num | 0 | 作用尚不明确 | +| his_rank | num | 历史最高排行 | | +| like | num | 获赞次数 | | +| dislike | num | 0 | 作用尚不明确 | +| no_reprint | num | 禁止转载标志 | 0无 1禁止 | +| copyright | num | 版权标志 | 1自制 2转载 | + +示例: + +http://api.bilibili.com/archive_stat/stat?aid=91572143 +``` +{ + "code": 0, + "message": "0", + "ttl": 1, + "data": { + "aid": 91572143, + "view": 2236510, + "danmaku": 37856, + "reply": 5723, + "favorite": 131317, + "coin": 143389, + "share": 44598, + "now_rank": 0, + "his_rank": 4, + "like": 264314, + "dislike": 0, + "no_reprint": 1, + "copyright": 1 + } +} +``` + +##视频状态数2 + +api.bilibili.com/x/web-interface/archive/stat + +*方式:GET* + +参数: +| 参数名 | 内容 | 必要性 | 备注 | +| -------| -------- | ------ |------| +| aid | 视频avID | 必要 | | + + +**json回复** +| 字段 | 类型 | 内容 | 备注 | +| ------- | ----- | --------- | -------------------------------- | +| code | num | 返回值 | 0成功 -400请求错误 40003无视频 | +| message | str | 错误信息 | 默认为0 | +| ttl | num | 1 | 作用尚不明确 | +| data | obj | 信息本体 | | + +data 对象: +| 字段 | 类型 | 内容 | 备注 | +| ---------- | ----- | ------------ | ---------------- | +| aid | num | 视频avID | | +| bvid | str | | | +| view | num | 观看次数 | 屏蔽时为str:"--" | +| danmaku | num | 弹幕条数 | | +| reply | num | 评论条数 | | +| favorite | num | 收藏人数 | | +| coin | num | 投币枚数 | | +| share | num | 分享次数 | | +| now_rank | num | 0 | 作用尚不明确 | +| his_rank | num | 历史最高排行 | | +| like | num | 获赞次数 | | +| dislike | num | 0 | 作用尚不明确 | +| no_reprint | num | 禁止转载标志 | 0无 1禁止 | +| copyright | num | 版权标志 | 1自制 2转载 | +| argue_msg | str | 警告信息 | 默认为空 | +| evaluation | str | 视频评分 | 默认为空 | + +示例: + +http://api.bilibili.com/x/web-interface/archive/stat?aid=2271112 +``` +{ + "code": 0, + "message": "0", + "ttl": 1, + "data": { + "aid": 2271112, + "bvid": "", + "view": 25719725, + "danmaku": 159249, + "reply": 52007, + "favorite": 879004, + "coin": 586071, + "share": 235709, + "like": 594645, + "now_rank": 0, + "his_rank": 4, + "no_reprint": 0, + "copyright": 1, + "argue_msg": "", + "evaluation": "" + } +} +``` + + +