Code Monkey home page Code Monkey logo

biliauth's Introduction

Bili-Auth

(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');
参数名 必须 描述
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');
参数名 必须 描述
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);
参数名 必须 描述
cookie COOKIE
{
	"code": 0,
	"status": "valid",
	"message": "检测 Cookie 有效!"
}

刷新令牌时效

$api->refreshToken($access, $refresh);
参数名 必须 描述
access ACCESS_TOEKN
refresh REFRESH_TOEKN
{
	"code": 0,
	"data": {
		"mid": 123456,
		"refresh_token": "698d51a19d8a121ce581499d7b701668",
		"access_token": "b59c67bf196a4758191e42f76670ceba",
		"expires_in": "2018-11-11 11:11:11"
	},
	"message": "续签令牌: 成功!"
}

检测令牌有效性

$api->checkToken($access);
参数名 必须 描述
access ACCESS_TOEKN
{
	"code": 0,
	"status": 1,
	"message": "令牌验证成功,有效期至: 2018-11-11 11:11:11"
}

状态

B站的状态码很混乱,后面陆续记录一些

状态码 描述
0 正常
200 CURL返回的
-105 登陆需要验证码
629 账号密码错误
1024 超时
403 IP问题

TODO

  • 待定

Author

Bili-Auth © lkeme, Released under the MIT License.

Blog @lkeme · GitHub @lkeme

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.