lkeme / bili-auth
BILIBILI网站登陆API盒子.
v0.0.1
2018-10-05 10:04 UTC
Requires
- php: >=5.6.0
- ext-curl: *
- ext-openssl: *
Suggests
- ext-bcmath: Required to use BC Math calculate RSA.
- ext-openssl: Required to use OpenSSL encrypt params.
This package is auto-updated.
Last update: 2024-11-06 10:33:30 UTC
README
(BILIBILI) B站登陆API盒子
环境依赖
PHP 5.6+ Curl, OpenSSL extension installed.
Note: BiliAuth requires cURL and OpenSSL extension in order to work.
安装程序
需要安装: Composer
$ composer require lkeme/bili-auth
快速开始
在你的项目中引用代码:
use Lkeme\BiliAuth; $api = new BiliAuth(); $data = $api->login('username','password');
所有方法
登陆
$api->login('username', 'password');
{ "code": 0, "data": { "uid": 123456, "userName": "123456", "accessToken": "81dc9bdb52d04dc20036dbd8313ed055", "refreshToken": "202cb962ac59075b964b07152d234b70", "cookieInfo": "bili_jct=...;DedeUserID=...;DedeUserID__ckMd5=...;sid=...;SESSDATA=...;", "csrfToken": "827ccb0eea8a706c4c34a16891f84e7b", "expires_in": "2018-11-11 11:11:11" }, "message": "账号登陆成功!" }
验证码登陆
需要先获取验证码
$api->login('username', 'password', 'captcha', 'cookie');
{ "code": 0, "data": { "uid": 123456, "userName": "123456", "accessToken": "81dc9bdb52d04dc20036dbd8313ed055", "refreshToken": "202cb962ac59075b964b07152d234b70", "cookieInfo": "bili_jct=...;DedeUserID=...;DedeUserID__ckMd5=...;sid=...;SESSDATA=...;", "csrfToken": "827ccb0eea8a706c4c34a16891f84e7b", "expires_in": "2018-11-11 11:11:11" }, "message": "账号登陆成功!" }
获取验证码(验证码登陆前提)
$api->getCapcha();
{ "code": 200, "cookie": "kxMAJX6f", "captcha_img": "base64图片", "bash64_head": "data:image/jpg/png/gif;base64,", "message": "获取验证码图片(Base64)!" }
检测COOKIE有效性
$api->checkCookie($cookie);
{ "code": 0, "status": "valid", "message": "检测 Cookie 有效!" }
刷新令牌时效
$api->refreshToken($access, $refresh);
{ "code": 0, "data": { "mid": 123456, "refresh_token": "698d51a19d8a121ce581499d7b701668", "access_token": "b59c67bf196a4758191e42f76670ceba", "expires_in": "2018-11-11 11:11:11" }, "message": "续签令牌: 成功!" }
检测令牌有效性
$api->checkToken($access);
{ "code": 0, "status": 1, "message": "令牌验证成功,有效期至: 2018-11-11 11:11:11" }
状态
B站的状态码很混乱,后面陆续记录一些
TODO
- 待定
Author
Bili-Auth © lkeme, Released under the MIT License.