florianorineveu/ow-api-php

为 Ow-API 提供的 PHP 封装

1.0.4 2024-03-26 22:14 UTC

This package is auto-updated.

Last update: 2024-09-26 23:25:58 UTC


README

MIT License Current Version

概览

此仓库包含 Ow-API 的非官方 PHP 封装。

API 资源和响应示例在 官方文档 中。

目录

兼容性

此库需要 PHP v7.1 或更高版本。

安装

使用以下代码安装封装

composer require fnev-eu/ow-api-php

如何使用

示例

<?php

require 'vendor/autoload.php';

use \OwAPI\Client;

$client = new Client(); 

// Get profile data for player Ori#21337 (it's me!), 
$response = $client->profile(Client::PLATFORMS['PC'], Client::REGIONS['EU'], 'Ori#21337');

// Read the response
if ($response->isSuccess()) {
    echo $response->getBody()['name'];
}

// Other available methods:
// - ALL profile data, heavy endpoint
$completeStats = $client->completeStats(Client::PLATFORMS['PC'], Client::REGIONS['EU'], 'Ori#21337');

// - Get profile data for specific heroes:
$heroesStats = $client->heroes(
    Client::PLATFORMS['PC'],
    Client::REGIONS['EU'],
    'Ori#21337',
    ['brigitte', 'mercy', 'ana']
);

profilecompleteStatsheroes 方法将返回一个包含以下方法的 Response 对象

  • isSuccess: 返回一个布尔值,指示 API 调用是否成功
  • getStatus: HTTP 状态码
  • getBody: 来自 JSON 响应的 PHP 关联数组
  • getRequestgetRawResponse 可帮助您进行调试

贡献

请随时提问并贡献

  • 分支项目
  • 创建一个新分支
  • 实现您的想法或修复问题
  • 提交、推送并打开一个 pull request!