boo / bnet
Library for working with the Battle.net Web APIs.
Installs: 153
Dependents: 0
Suggesters: 0
Security: 0
Stars: 27
Watchers: 11
Forks: 14
Open Issues: 2
Requires
- php: >=5.5
- guzzlehttp/guzzle: ^6.0
- league/oauth2-client: ^1.0
- psr/cache: ^1.0
- sebastian/version: ^1.0 || ^2.0
Requires (Dev)
- fig/cache-util: dev-master
- friendsofphp/php-cs-fixer: ^1.11
- jakub-onderka/php-parallel-lint: ^0.9
- mockery/mockery: ^0.9
- phpunit/phpunit: ^4.8
- satooshi/php-coveralls: ^1.0
This package is auto-updated.
Last update: 2024-10-29 05:34:22 UTC
README
boo/bnet is a PHP 7.1+ library for working with the Battle.net APIs.
Installation
The preferred method of installation is via Packagist and Composer. Run
the following command to install the package and add it as a requirement to your
project's composer.json
:
composer require boo/bnet
Usage
API
The boo/bnet library is able to generate PSR-7 requests for all Battle.net API endpoints. In order to do so, a request factory implementing PSR-17, as well as a PSR-7 compatible HTTP client, is required. The example below uses http-interop/http-factory-guzzle and guzzlehttp/guzzle, but any PSR-17 implementation and PSR-7 compatible HTTP client will work.
use Boo\BattleNet\Apis\Warcraft\CharacterProfileApi; use Boo\BattleNet\Regions\EU; use GuzzleHttp\Client; use Http\Factory\Guzzle\RequestFactory; $api = new CharacterProfileApi( new RequestFactory(), // Implementation of PSR-17 new EU(), // API region '3797fb20f11da97fbc5fc9335247883c' // API key ); $request = $api->getCharacterProfile('Draenor', 'Jyggen'); $client = new Client(); // PSR-7 compatible HTTP client $response = $client->send($request); var_dump($response);
OAuth 2.0
The boo/bnet library ships with a provider for league/oauth2-client.
use Boo\BattleNet\OAuth2\BattleNetProvider; $provider = new BattleNetProvider([ 'clientId' => '3797fb20f11da97fbc5fc9335247883c', 'clientSecret' => '7daf46a2c8a780582c6e46e71e5158fd', 'redirectUri' => 'https://localhost/oauth', 'region' => new EU(), ]);
Copyright and License
The boo/bnet library is copyright © Jonas Stendahl and licensed for use under the MIT License (MIT). Please see LICENSE for more information.