This package allows to call the Battle.net API.
Once installed you can do stuff like this:
use Xklusive\BattlenetApi\Services\WowService;
public function index(WowService $wow)
{
$achievement = $wow->getAchievement(2144);
dd($achievement);
//Ouput:
//Collection {#236 ▼
// #items: array:10 [▼
// "id" => 2144
// "title" => "Voyages au bout du monde"
// "points" => 50
// "description" => "Accomplir les hauts faits des évènements mondiaux listés ci-dessous."
// "reward" => "Récompense : proto-drake pourpre"
// "rewardItems" => array:1 [▶]
// "icon" => "achievement_bg_masterofallbgs"
// "criteria" => array:8 [▶]
// "accountWide" => true
// "factionId" => 2
// ]
}
Before you be able to make requests to the Battle.net API, you need to provide your API key. If you don't have an API key, refer to https://dev.battle.net/docs to get your API key. Without a Battle.net API key, the package will not be functionnal.
You can install the pacakge via composer:
$ composer require xklusive/laravel-battlenet-api
Then this provider must be installed :
// config/app.php
'providers' => [
...
Xklusive\BattlenetApi\BattlenetApiServiceProvider::class,
];
The last required step is to publish configuration's file in your application with :
$ php artisan vendor:publish --provider="Xklusive\BattlenetApi\BattlenetApiServiceProvider" --tag="config"
This is the content of the published config file:
// config/battlenet-api.php
return [
/*
|--------------------------------------------------------------------------
| Laravel Battle.net Api configuration
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| Battle.net API credentials
|--------------------------------------------------------------------------
|
| Before you be able to make requests to the Battle.net API, you need to provide your API key.
| If you don't have an API key, refer to https://dev.battle.net/docs to get an API key
|
*/
'api_key' => 'YOUR_API_KEY',
/*
|--------------------------------------------------------------------------
| Battle.net Locale
|--------------------------------------------------------------------------
|
| Define what locale to use for the Battle.net API response.
| For examples: en_GB | fr_FR | de_DE | ru_RU
|
*/
'locale' => 'en_GB',
/*
|--------------------------------------------------------------------------
| Battle.net api domain
|--------------------------------------------------------------------------
|
| Define the region API.
| Change [region] by the value of your choice
| You can refer to the Battle.net API documentation https://dev.battle.net/io-docs
| For example, if you want to request on the Europe region: 'https://eu.api.battle.net'
|
*/
'domain' => 'https://[region].api.battle.net',
/*
|--------------------------------------------------------------------------
| Battle.net api cache
|--------------------------------------------------------------------------
|
| Define is the response body content is put in cache (default cache time is 10 hours),
| using the cache driver for your application as specified by your cache configuration file.
| Set it to false if you don't want that we manage cache.
|
*/
'cache' => true,
/*
|--------------------------------------------------------------------------
| Battle.net api cache
|--------------------------------------------------------------------------
|
| If cache is set to true, you can change here the cache time duration
| This value is in minutes.
|
*/
'cache_duration' => 600,
];
Congratulations, you have successfully installed Laravel Battle.net API !