udwio/alpine-chi-poppet

PHP 客户端,用于消耗 Path of Exile 开发者 API。Alpine Chi Poppet 是 "php poe api client" 的字母重组

这个包的官方仓库似乎已丢失,因此该包已被冻结。

v0.0.2 2019-11-25 12:19 UTC

This package is auto-updated.

Last update: 2024-08-13 19:00:05 UTC


README

描述

一个用 PHP 编写的库,用于从公共 Path of Exile API 获取数据。

该名称是 php-poe-api-client 的字母重组

有一个顶级类 source/AlpineChiPoppet/AlpineChiPoppet.php,它提供了对库的同步访问和一些方便的辅助方法。

为了获得更细粒度的控制,每个端点在 source/AlpineChiPoppet/<endpoint>/<endpoint.php> 中都有相应的类,其中包含适当的方法。#TODO 由于这将会受到严格的速率限制

独立安装

    cd /path/to/project
   composer require udwio/alpine-chi-poppet

Laravel 安装

快速入门

    # Run the frontend cli for quick and dirty examples of how to use the library
    php scripts/acp-cli.php examples

    # you can execute a manual query for testing the live API with the CLI by following the help directions
    php scripts/acp-cli.php run --help
    
    # e.g.
    php scripts/acp-cli.php run -i "SSF+Heist+HC" -l 200 -o 0 -u true | less

AlpineChiPoppet 类和辅助方法

当包含 AlpineChiPoppet 类时可以访问这些辅助方法。AlpineChiPoppet 类提供对库其他部分的快速访问。为了获得更细粒度的控制,请包含底层端点类。所有这些方法都是同步执行的,即它们是阻塞的。

    /** /ladders/ **/
    public function getLeagueLadder(Array $a): array;
    public function getLabyrinthLadder(Array $a): array;
    public function getTempSCLadder(): array;
    public function getTempHCLadder(): array;
    public function getTempSSFSCLadder(): array;
    public function getTempSSFHCLadder(): array;
    public function getCsvLadder(Array $a, String $filePath);

    /** /seasons/ **/
    public function listSeasons(): Array;

    /** /character-window/ **/
    public function getCharacters(Array $pConf): string; 
    public function getItems(): string; // not implemented
    public function getPassiveSkills(): string; // not implemented
    public function getStashItems(): string; // not implemented
    public function getMtxStashItems(): string; // not implemented
    public function getAccountNameByCharacter(): string; // not implemented

    /** /pvp-matches/ **/
    public function getPvPMatches(): string; /// not implemented

    /** /public-stash-tabs/ **/
    public function getPublicStashTabs(): string; // not implemented

    /** /shop/microtransactions/specials **/
    public function getMtxSpecials(): string; //not implemented

    /** /trade/data/ **/
    public function getTradeDataLeagues(): string; // not implemented
    public function getTradeDataItems(): string; // not implemented
    public function getTradeDataStats(): string; // not implemented
    public function getTradeDataStatic(): string; // not implemented

    /** /trade/search/ **/
    public function postTradeSearch(); //not implemented

    /** /trade/fetch/ **/
    public function getResultsByString(): string; //not implemented

    /** /trade/ignore/ **/
    public function getIgnoredAccounts(): string; // not implemented
    public function putIgnoreAccount(); // not implemented
    public function deleteIgnoredAccount(); // not implemented

    /** /guild/ **/
    public function getGuildStashHistory(): string; //not implemented

    /** /leagues/ **/
    public function listLeagues(Array $a);
    
    /** /league-rules/ **/
    public function getLeagueRules(): string;
    public function getSingleRule(Array $a): array;

独立使用

在源目录中,请求按端点分组。例如: https://api.pathofexile.com/ladders/ 位于 source/AlpineChiPoppet/Ladders/

PHP 项目中的示例使用

use AlpineChiPoppet\AlpineChiPoppet;

class MyExampleClass 
{
    $config = 'path/to/config/file'; // default is supplied in vendor directory.
    $acp = new AlpineChiPoppet($config);

    $results = $acp->getTempHCLadder();

    print($results);

}

示例控制台输出


配置

默认值可以在 ./source/AlpineChiPoppet/Support/Config/acp.php 中找到。

POESESSID

警告 不要将此值提交到您的版本控制系统

某些端点需要在请求中发送 POESESSID cookie 以进行身份验证。

  • 创建自己的配置文件副本。例如: cp source/AlpineChiPoppet/Config/acp.php tmp/acp-with-auth.php
  • 将您的应用程序指向新的配置文件。例如,如果使用测试 CLI 工具,请使用 -c 选项 php scripts/acp.php command -c /path/to/config/file
  • 使用浏览器登录 Path of Exile 网站。
  • 找到名为 POESESSID 的 cookie。这是浏览器特定的,您需要自己查找。
  • 将此 cookie 的值复制到新配置文件中的 poe_session_id 下方。
  • scheme 的值更改为 https

在 Laravel 项目中,将此文件发布到 config 文件夹,使其优先于 vendor/udwio/AlpineChiPoppet/.... 中的默认配置文件。

    php artisan vendor:publish --provider=AlpineChiPoppet

缓存

如果您选择使用缓存选项,可以在 AlpineChiPoppet 配置文件中启用它们。

确保您的 PHP 版本已启用正确的扩展

获取帮助

检查 scripts/acp-cli.php 脚本以获取基本用法,并查看测试目录中的测试以了解如何使用库。

运行测试套件

composer run tests

以详细模式运行

composer run tests-verbose