johnleider/battlenet-api

一个用于从Blizzard的API获取信息的软件包

资助软件包维护!
feross

v2 2016-01-15 01:51 UTC

This package is not auto-updated.

Last update: 2024-09-24 03:30:01 UTC


README

用于Battle.net的API(http://dev.battle.net/)的软件包

使用方法

使用您的API密钥、API密钥和区域实例化您希望使用的游戏API

$diablo = new Diablo(
  $key,
  $secret,
  'us',
  'en_US'
);

示例API调用

// Retrieve Season Leaderboard data
$diablo = new Diablo($key, $secret, 'us', 'en_US');
$diablo->setAccessToken($accessToken);

$barbarian = $diablo->season($season)
	->barbarian()
	->get();
	
$barbarian_hardcore = $diablo->season($season)
	->hardcore()
	->barbarian()
	->get();

$profile = $diablo->careerProfile('battle_tag');
$hero = $diablo->hero('battle_tag', 'id');

请求池

您可以通过在调用get()之前链式请求来池化多个请求。

$diablo = new Diablo($key, $secret, 'us', 'en_US');
$diablo->setAccessToken($accessToken);

$leaderboards = $diablo->season($season)
	->barbarian()
	->crusader()
	->demonhunter()
	->monk()
	->witchdoctor()
	->wizard()
	->team(2)
	->team(3)
	->team(4)
	->get();
	
$profile = $diablo->setRegion('eu')
	->careerProfile($battle_tag)
	->get();
	
foreach ($request->heroes as $hero) {
	$diablo->hero($hero->id);
}

$heroes = $diablo->get();

这将异步地每次请求25个并发请求。响应将返回JSON对象的数组。调用将不会在调用get方法之前发出。