๐Ÿ“ฆ johnleider / battlenet-api

PHP API for Battlenet API

โ˜… 5 stars โ‘‚ 1 forks ๐Ÿ‘ 5 watching
๐Ÿ“ฅ Clone https://github.com/johnleider/battlenet-api.git
HTTPS git clone https://github.com/johnleider/battlenet-api.git
SSH git clone git@github.com:johnleider/battlenet-api.git
CLI gh repo clone johnleider/battlenet-api
John Leider John Leider Updated all classes to use addToRequest method. 7914ca4 9 years ago ๐Ÿ“ History
๐Ÿ“‚ master View all commits โ†’
๐Ÿ“ src
๐Ÿ“„ .gitignore
๐Ÿ“„ composer.json
๐Ÿ“„ composer.lock
๐Ÿ“„ README.md
๐Ÿ“„ README.md

battlenet-api

A package for Battle.net's API (http://dev.battle.net/)

Usage

Instantiate the game API you wish to use with your API Key, API Secret and Region

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

Example API calls:

// 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');

Pooling Requests

You can pool multiple requests by chaining requests before calling 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();

This will asynchronously request 25 concurrent requests at a time. The response will return as an array of JSON objects. The call will not be made until the get method is called.