PHP code example of airmole / tjustb-libsp

1. Go to this page and download the library: Download airmole/tjustb-libsp library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

airmole / tjustb-libsp example snippets




irmole\TjustbLibsp\Libsp;

$libsp = new Libsp();

// 示例 1:获取热门搜索
$hotKeywords = $libsp->popularSearchSimple();
print_r($hotKeywords);

// 示例 2:统一检索(关键词)
$result = $libsp->search(
    searchFieldContent: '机器学习',
    searchField: 'keyWord',
    page: 1,
    rows: 10
);
print_r($result);

// 示例 3:图书详情(recordId 需从检索结果中获取)
$detail = $libsp->bookDetail(123456);
print_r($detail);



use Airmole\TjustbLibsp\Libsp;

try {
    $libsp = new Libsp();
    $result = $libsp->search(searchFieldContent: '数据库');
} catch (\Throwable $e) {
    // 记录日志 + 业务降级
    error_log($e->getMessage());
}

src/
├── Base.php          # 基础类:HTTP 请求、Cookie 管理、配置读取
├── Libsp.php         # 对外聚合类(推荐使用)
├── Login.php         # SSO 登录相关
├── Search.php        # 检索与书目详情
├── Popular.php       # 热门搜索、热门借阅、最新图书
├── User.php          # 用户信息与借阅管理
├── BookList.php      # 书单管理
├── Score.php         # 读者积分
├── Misc.php          # 数据字典
└── Exception/
    └── Exception.php # 自定义异常