danaketh / blizzard-client
Blizzard API客户端
dev-master
2018-08-23 10:28 UTC
Requires
- php: ^7.1
This package is auto-updated.
Last update: 2024-09-24 04:50:35 UTC
README
PHP库,简化与Blizzard API的工作。
此包正在积极开发中,可能会发生重大变化!
需求
- PHP 7.1+
安装
composer require danaketh/blizzard-client
使用
您需要一个开发者账户,这将允许您生成API密钥和密钥,它们是使用客户端所必需的。您可以在[Battle.net开发者门户](https://dev.battle.net/)(https://dev.battle.net/member/register)(创建账户)上注册。
当您获取到密钥和密钥时,请确保您**绝对不要**在任何人都可以获取的地方(如项目仓库或网站公开目录)包含它们。
use danaketh\Blizzard\Exception\InvalidRegionException;
use danaketh\Blizzard\Game\WoW\API;
use danaketh\Blizzard\Game\WoW\Common\Region;
$api = new API('<API_KEY>', '<API_SECRET>');
// Set region
try {
$api->setRegion(Region::Europe);
} catch (InvalidRegionException $e) {
die($e->getMessage());
}
// Now get the realms endpoint
$realms = $api->realm();
foreach ($realms->findAll() as $r) {
var_dump($r);
}