Skip to content
/ bnet Public

Battle.net API Client - A PHP 7.1+ library for working with the Battle.net APIs.

License

Notifications You must be signed in to change notification settings

jyggen/bnet

Repository files navigation

Battle.net API Client

Source Code Latest Version Software License Build Status Coverage Status Total Downloads

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.

About

Battle.net API Client - A PHP 7.1+ library for working with the Battle.net APIs.

Resources

License

Stars

Watchers

Forks

Packages

No packages published