dolejska-daniel / riot-api

Riot League of Legends & DataDragon API wrappers for PHP7 and PHP8.
GNU General Public License v3.0
112 stars 25 forks source link

Help Wanted SettingsException #94

Closed EmanueleSpadaro closed 3 years ago

EmanueleSpadaro commented 3 years ago

Hi! I was trying to test this wrapper and followed line by line all of your instructions, but whenever i try to run the initialization code I get a RiotAPI\LeagueAPI\Exceptions\SettingsException and i'm having a hard time trying to find out why! This is the code:

<?php
//  Include all required files (installation via Composer is required)
require_once __DIR__  . "/vendor/autoload.php";

use RiotAPI\LeagueAPI\LeagueAPI;
use RiotAPI\LeagueAPI\Definitions\Region;

//  Initialize the library
$api = new LeagueAPI([
    //  Your API key, you can get one at https://developer.riotgames.com/
    LeagueAPI::SET_KEY    => 'RGAPI-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
    //  Target region (you can change it during lifetime of the library instance)
    LeagueAPI::SET_REGION => Region::EUROPE_EAST,
    LeagueAPI::SET_VERIFY_SSL => false
]);

//  And now you are ready to rock!
$ch = $api->getStaticChampion(61); // Orianna <3
dolejska-daniel commented 3 years ago

Hello! What does the exception say?

EmanueleSpadaro commented 3 years ago

Hi! This is the exception message: DataDragon API was not initialized properly! StaticData endpoints cannot be used.

EmanueleSpadaro commented 3 years ago

Apparently I cannot send Static Requests, other stuff works fine like Summoner Endpoint for example. Is it a bug or something?

dolejska-daniel commented 3 years ago

Oh I see! You are trying to call $api->getStaticChampion(61) which depends on DataDragonAPI library being initialized—that can be done by adding LeagueAPI::SET_DATADRAGON_INIT => true to LeagueAPI settings array.

But you are right of course, this is my bad, providing this snippet as minimalistic working example when it doesn't work as provided.

EmanueleSpadaro commented 3 years ago

That's awesome to hear, I would consider updating the example then! Thank you for your time!