boo/bnet

Library for working with the Battle.net Web APIs.

0.1.1 2016-07-05 16:57 UTC

This package is auto-updated.

Last update: 2024-03-29 03:59:15 UTC


README

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.