florianorineveu / ow-api-php
为 Ow-API 提供的 PHP 封装
1.0.4
2024-03-26 22:14 UTC
Requires
- php: ^7.1|^8.0
- ext-json: *
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
- phpunit/phpunit: ^9.0
README
概览
此仓库包含 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'] );
profile
、completeStats
和 heroes
方法将返回一个包含以下方法的 Response
对象
isSuccess
: 返回一个布尔值,指示 API 调用是否成功getStatus
: HTTP 状态码getBody
: 来自 JSON 响应的 PHP 关联数组getRequest
和getRawResponse
可帮助您进行调试
贡献
请随时提问并贡献
- 分支项目
- 创建一个新分支
- 实现您的想法或修复问题
- 提交、推送并打开一个 pull request!