francis-schiavo/blizzard_api
最新稳定版本:v0.2.0
Composer 安装命令:
composer require francis-schiavo/blizzard_api
包简介
PHP client for Blizzard web APIs
关键字:
README 文档
README
This library is an interface to Blizzard APIS.
See https://develop.battle.net/ for more information.
Installation
This library requires PHP 8.1 or newer with the following modules:
- mbstring
- curl
- redis (Only if using the Redis cache interface)
You can add this library to your compose project by adding
francis-schiavo/blizzard_api as a requirement on your compose.json.
or from the command line:
php composer.phar require francis-schiavo/blizzard_api
Configuration
You must configure the package with a valid pair of credentials. You can obtain them here: https://develop.battle.net/access/clients
The code sample below show how to configure the library.
<?php use BlizzardApi\Enumerators\Region; BlizzardApi\Configuration::$apiKey = '<YOUR APPLICATION ID>'; BlizzardApi\Configuration::$apiSecret = '<YOUR APPLICATION SECRET>'; BlizzardApi\Configuration::$region = Region::US;
Basic usage
This is how you can get a list of all available wow playable races:
$api_client = new \BlizzardApi\Wow\GameData\PlayableRace(); $data = $api_client->index(); echo(print_r($data));
You can pass an instance of RedisCache to use Redis to cache API requests locally:
# PHP Redis module $redis = new Redis(); $redis->connect('127.0.0.1', 6379); $redis->select(8); # BlizzardApi\Cache use BlizzardApi\Cache\RedisCache; $cache = new RedisCache($redis); # Pass the constructor `cache` parameter. $api_client = new \BlizzardApi\Wow\GameData\PlayableRace(cache: $cache); $data = $api_client->index();
Advanced search interface
For some WoW endpoints there is a search method available, you can easily
compose a valid query as shown here:
# Pass the constructor `cache` parameter. $api_client = new \BlizzardApi\Wow\GameData\Item(cache: $cache); $data = $api_client->search(function($queryOptions) { $searchOptions->where('name.en_US', 'Booterang')->order_by('id'); });
统计信息
- 总下载量: 228
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-08-21