Skip to content

cuanmaster/DramaBox-API-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dramabox PHP SDK — README (EN)

This repository is a PHP SDK to call Dramabox APIs (hosted under sapi.dramaboxdb.com), plus a small test.php example that calls NewList and returns JSON.

For PHP developers who want a quick integration and will customize request headers/signatures to match their own device/token.


File layout

.
├── DramaboxApp.php     # Signature helper using your private key
├── DramaboxApi.php     # API wrappers: NewList, searchSuggest, ...
├── test.php            # Tiny example endpoint calling NewList and echoing JSON
└── private_key.pem     # (required) private key used by openssl_sign

Important: put private_key.pem next to DramaboxApp.php. Make sure the key matches what the server expects.


Requirements

  • PHP 8.1+ (8.2+ recommended)
  • openssl extension enabled
  • Outbound internet access to https://sapi.dramaboxdb.com/

Check extensions:

php -m | grep openssl

Setup

  1. Extract the files into a working folder (e.g., /var/www/dramabox/).

  2. Prepare private_key.pem

    • Place it in the same folder as DramaboxApp.php.
    • Suggested permissions 0600 and owned by your PHP/web user.
  3. Configure constants in DramaboxApi.php Open and set real values:

    const DRBX_BEARER  = "Bearer token"; // e.g. "Bearer eyJhbGciOi..."
    const DRBX_DEVICE  = "DEVICE";       // device id / UUID
    const DRBX_ANDROID = "ANDROID";      // android id
    const DRBX_USER_ID = "XXXXXXXX";     // user id

    You can tweak/add headers in base_headers() and use DramaboxApp::dramabox() to produce the sn signature header per endpoint.


Quick start (local test)

Run a local PHP server:

php -S 127.0.0.1:8080 -t .

Call the sample endpoint:

curl "http://127.0.0.1:8080/test.php?pageNo=1&pageSize=15&lang=en"

Sample result:

{
  "success": true,
  "data": {
    "list": [ { "bookId": 123, "bookName": "..." } ],
    "isMore": true,
    "total": 15,
    "raw": { "...": "upstream payload" }
  }
}

Usage (as a library)

1) NewList

<?php
require_once __DIR__ . '/DramaboxApi.php';

$pageNo = 1; $pageSize = 20; $lang = 'en';
$typeList = DEFAULT_TYPE_LIST; // or your own type

$result = api_NewList($pageNo, $pageSize, $typeList, $lang);
print_r($result);

2) searchSuggest

<?php
require_once __DIR__ . '/DramaboxApi.php';

$suggest = api_searchSuggest('love', 'en');
foreach ($suggest as $row) {
    echo $row['name'] ?? $row['keyword'], "
";
}

3) searchByKeyword

<?php
require_once __DIR__ . '/DramaboxApi.php';

$kw = 'romance';
$data = api_searchByKeyword($kw, pageNo:1, pageSize:20, lang:'en');
var_dump($data);

4) listChapters

<?php
require_once __DIR__ . '/DramaboxApi.php';

$bookId = 123456;
$chapters = api_listChapters($bookId, 'en');
print_r($chapters);

5) batchDownload

<?php
require_once __DIR__ . '/DramaboxApi.php';

$bookId = 123456;
$chapterIds = [111,112,113];
$payload = api_batchDownload($bookId, $chapterIds, 'en');
// Inspect links/metadata returned by the upstream API

The actual function names provided by DramaboxApi.php may include: api_latestList, api_NewList, api_searchSuggest, api_searchByKeyword, api_listChapters, api_batchDownload.


Headers & signature

  • DramaboxApi.php builds standard headers in base_headers() such as Authorization, device, platform, userId, language, etc.
  • Some endpoints require sn (SHA256 with RSA over a specific string/body). Use DramaboxApp::dramabox($string).
  • If the server expects a specific canonicalization (key order, JSON string, pre-hash), mirror that in your signer.

Example (conceptual):

$body = [ 'keyword' => $keyword ];
$headers = base_headers();
$headers['sn'] = create_signature($body); // calls DramaboxApp::dramabox internally
$headers['language'] = $lang;
$headers['current-language'] = $lang;

License

MIT for the sample code unless you specify otherwise in your project.


Credits

  • Signature/header structure inspired by reverse-engineering Dramabox app traffic for private integration/testing. Use responsibly and respect the service terms.

About

Test API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages