legionth/igdb-reactphp-client

v0.2.0 2018-09-24 16:21 UTC

This package is auto-updated.

Last update: 2024-08-27 03:25:16 UTC


README

基于ReactPHP的异步事件驱动的IGDB API实现。

目录

用法

此示例将创建一个客户端,连接到官方IGDB API](https://api.igdb.com/).

这里使用了对成就的API调用。

require __DIR__ . '/vendor/autoload.php';

$loop = React\EventLoop\Factory::create();

$httpClient = new \Legionth\React\Http\Client($loop);

$apiKey = '<enter-your-api-key>';

$igdbClient = new \Legionth\React\IGDB\IgdbClient($apiKey, $httpClient);

$promise = $igdbClient->getAchievements(array(1440, 5000));

$promise->then(function (array $array){
    echo "Array: " . json_encode($array, JSON_PRETTY_PRINT);
}, function (\Exception $exception) {
    echo $exception->getMessage();
});

IgdbClient中的所有方法都将返回一个ReactPHP Promise,这将导致包含所有API响应信息的数组。Promise用于处理高度异步,因此可以异步地调用多个调用,而无需担心阻塞代码。

通用

API密钥

要使用此库,您必须注册IGDB API的帐户。此API必须传递给库才能工作。

请求限制

请注意,可能有对IGDB API的请求限制。检查文档以增加API调用。

支持的端点

目前,此库支持几个端点。

    Achievements
    Character
    Collection
    Company
    Credits
    External Review
    External Review Source
    Feed
    Franchise
    Game
    Game engine
    Game mode
    Genre
    Keyword
    Page
    Person
    Platform
    Play Times
    Player Perspective
    Pulse
    Pulse Group
    Pulse Source
    Release date
    Review
    Theme
    Title
    User Profile
    Versions

如果任何端点缺失或已更改,请随意提交拉取请求以提供帮助。

安装

新手Composer?

这将安装最新支持的版本

$ composer require legionth/igdb-client-reactphp:^0.1

许可

MIT