2017 © Pedro Peláez
 

library bnet

Library for working with the Battle.net Web APIs.

image

pwnraid/bnet

Library for working with the Battle.net Web APIs.

  • Monday, February 5, 2018
  • by jyggen
  • Repository
  • 6 Watchers
  • 27 Stars
  • 1,159 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 12 Forks
  • 5 Open issues
  • 4 Versions
  • 2 % Grown

The README.md

Battle.net API Client

![Source Code][badge-source] Latest Version ![Software License][badge-license] Build Status [![Coverage Status][badge-coverage]][coverage] Total Downloads, (*1)

boo/bnet is a PHP 7.1+ library for working with the Battle.net APIs., (*2)

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:, (*3)

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., (*4)

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., (*5)

use Boo\BattleNet\OAuth2\BattleNetProvider;

$provider = new BattleNetProvider([
    'clientId' => '3797fb20f11da97fbc5fc9335247883c',
    'clientSecret' => '7daf46a2c8a780582c6e46e71e5158fd',
    'redirectUri' => 'https://localhost/oauth',
    'region' => new EU(),
]);

The boo/bnet library is copyright © Jonas Stendahl and licensed for use under the MIT License (MIT). Please see LICENSE for more information., (*6)

The Versions