aneeskhan47/php-howlongtobeat-api 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

aneeskhan47/php-howlongtobeat-api

最新稳定版本:v1.0.3

Composer 安装命令:

composer require aneeskhan47/php-howlongtobeat-api

包简介

A PHP API wrapper for HowLongToBeat.com

README 文档

README

PHP HowLongToBeat API

GitHub Workflow Status (master) Total Downloads Latest Version License

A simple PHP API to read data from HowLongToBeat.com.

It is inspired by ScrappyCocco - HowLongToBeat-PythonAPI Python API.

⚡️ Installation

Requires PHP 7.4 or higher

composer require aneeskhan47/php-howlongtobeat-api

🚀 Usage

Search for games by title

by default, it will return 25 results per page and the first page.

require 'vendor/autoload.php';

use AneesKhan47\HowLongToBeat\HowLongToBeat;

$hltb = new HowLongToBeat();

try {
    $results = $hltb->searchByTitle("The Last of Us");

    foreach ($results->games as $game) {
        echo "Game: " . $game->name . "\n";
        echo "Image: " . $game->image_url . "\n";
        echo "Main Story: " . $game->main_story_time . "\n";
        echo "Main + Extra: " . $game->main_extra_time . "\n";
        echo "Completionist: " . $game->completionist_time . "\n";
        echo "------------------------\n";
    }
} catch (Exception $e) {
    echo "Error: " . $e->getMessage();
}

You can also specify the number of results per page. for example, to get second page with 10 results per page, you can do this:

$results = $hltb->searchByTitle("The Last of Us", 2, 10);

Note: The maximum number of results per allowed is 25. This is by HowLongToBeat.com limitation.

Search for a single game by its ID

$game = $hltb->searchById(26286);

echo "Game: " . $game->name . "\n";
echo "Image: " . $game->image_url . "\n";
echo "Main Story: " . $game->main_story_time . "\n";
echo "Main + Extra: " . $game->main_extra_time . "\n";
echo "Completionist: " . $game->completionist_time . "\n";
echo "------------------------\n";

🔒 Security

If you discover any security-related issues, please email kingkhan2388@gmail.com instead of using the issue tracker.

🙌 Credits

📜 License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 94
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-01-25