Download the PHP package hejunjie/bililive without Composer
On this page you can find all versions of the php package hejunjie/bililive. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package bililive
Hejunjie\Bililive
English | 简体中文
A core PHP library for Bilibili live streaming WebSocket connections, providing interfaces for login, room operations, and danmu (bullet chat) stream encryption/decryption. Paired with long-running process solutions like Workerman, you can quickly build live room applications such as danmu monitoring, gift acknowledgments, scheduled ads, and auto-replies.
[!WARNING] This project is for learning and communication purposes only. Commercial or illegal use is strictly prohibited.
Want a quick overview? The codebase has been parsed by Zread.
Features
- Complete Bilibili QR code login flow with automatic cookie assembly
- Common live room operations: room info, danmu sending, mute management, online rankings, VIP count, and more
- WebSocket packet construction and parsing, with support for Brotli and Zlib encrypted data decryption
- Cookie-free support for select APIs (e.g., fetching basic user info)
- All methods are static — no instantiation required
Requirements
- PHP >= 8.0
- ext-brotli
- Composer
Installation
Quick Start
A minimal login → room info → WebSocket connection flow:
API Reference
Login
| Method | Description |
|---|---|
Login::getQrcode() |
Generate a login QR code |
Login::checkQrcode() |
Poll the QR code scan status; returns cookie on success |
Login::getUserInfo() |
Get basic info of the currently logged-in user |
Live
| Method | Description |
|---|---|
Live::getRealRoomId() |
Get the real room ID (resolves short room IDs) |
Live::getRealRoomInfo() |
Get live room basic info |
Live::getInitialWebSocketUrl() |
Get WebSocket connection details |
Live::getUserBarrageMsg() |
Get the user's danmu sending permissions for a room |
Live::sendMsg() |
Send a danmu message |
Live::reportLiveHeartbeat() |
Send web live heartbeat (every 60 seconds) |
Live::getOnlineGoldRank() |
Get the room's online ranking |
Live::addSilentUser() |
Mute a user in the room |
Live::getSilentUserList() |
Get the room's muted user list |
Live::delSilentUser() |
Unmute a user in the room |
Live::getVipNumbers() |
Get the number of VIP subscriptions (Guard) |
Live::getStreamerInfo() |
Get user basic info |
Live::getMasterInfo() |
Get basic info of a specified UID without cookie |
Live::getUserInfo() |
getStreamerInfo()) |
WebSocket
| Method | Description |
|---|---|
WebSocket::buildAuthPayload() |
Build authentication packet |
WebSocket::buildHeartbeatPayload() |
Build heartbeat packet |
WebSocket::parseResponsePayload() |
Parse response packets (auto-handles Brotli/Zlib decryption) |
Example: Danmu Monitor with Workerman
The following example demonstrates how to connect to a Bilibili live room using Workerman and listen for danmu messages, gifts, and follows. Implement your own business logic inside onMessageReceived.
Related Projects
| Project | Description |
|---|---|
| php-bilibili-danmu-core | Core Bilibili interaction module (this project) |
| php-bilibili-danmu-docker | One-click Docker deployment |
| php-bilibili-danmu | Main application |
| vue-bilibili-danmu-admin | Frontend: Admin dashboard |
| vue-bilibili-danmu-shop | Frontend: Mobile points shop |
Notes
- Traditional PHP-FPM is not well-suited for persistent connections due to its request-response model. Use long-running process solutions such as Workerman or Swoole.
- The
ext-brotliextension is required to decrypt WebSocket packets. Without it, danmu messages cannot be parsed correctly. Live::getUserInfo()is deprecated. UseLive::getStreamerInfo()instead.
All versions of bililive with dependencies
ext-brotli Version *