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 with Tournament Stub #96

Closed Lucasnl closed 3 years ago

Lucasnl commented 3 years ago

I'm trying to play with tournament stub , and create a tournament code, i've followed the wiki instructions but i keep getting the 403 error (forbidden)]

am I doing something wrong ? the api initialization maybe ?

thats my code :

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

//  Initialize
$api = new LeagueAPI([

    LeagueAPI::SET_TOURNAMENT_KEY =>'xxxxxxxxxxxxxx',
    LeagueAPI::SET_KEY    => 'xxxxxxxxxxxxxxxxx',

    LeagueAPI::SET_REGION => Region::BRASIL,
    LeagueAPI::SET_CACHE_CALLS => true,
    LeagueAPI::SET_CACHE_CALLS_LENGTH => 860,
    LeagueAPI::SET_CACHE_RATELIMIT => false,

]);

$callback_url = "https://webhook.site/1075e48a-8504-4ca9-af73-67e2859523c3" ; (a callback url just to test it)
$tournament_name = "Test Tournament";
$count = 1;

$providerParams = new Objects\ProviderRegistrationParameters([
    'region' => Region::BRASIL,
    'url'    => $callback_url,
]);

$provider_id = $api->createTournamentProvider($providerParams);

$tournamentParams = new Objects\TournamentRegistrationParameters([
    'providerId' => $provider_id,
    'name'       => $tournament_name,
]);

$tournament_id = $api->createTournament($tournamentParams);

 $codeParams = new Objects\TournamentCodeParameters([

    'mapType'       => 'SUMMONERS_RIFT',
    'pickType'      => 'ALL_RANDOM',
    'spectatorType' => 'ALL',
    'teamSize'      => 5,
]);

$codes = $api->createTournamentCodes($tournament_id, $count, $codeParams);
dolejska-daniel commented 3 years ago

Hello again! Is your API key tournament-approved by Riot? You first have to be allowed to use these endpoints.

Lucasnl commented 3 years ago

I have the development api key ,but even on tournament stub have i need a tournament key ? because at the riot developers site I can execute requests on the tournament stub with my key. Only on the regular tournament i can't , it says " cannot execute. this api endpoint is not available in your policy"

dolejska-daniel commented 3 years ago

Yes, you do need explicitly allowed access even for stub endpoints.

Lucasnl commented 3 years ago

thanks again for the help ! so where can i get this tournament key ? Do I Need to register an app on the riot developers site ?

dolejska-daniel commented 3 years ago

Yeah, please read everything there is at dev portal. Probably create an app, request dev key through notes, etc. You can also join official Discord - people there are amazing and very helpful.

Lucasnl commented 3 years ago

Thanks for your time and help ! Merry christmas and a happy new year !

dolejska-daniel commented 3 years ago

To you too! 💖🎉 Please do not forget to close the issue if solved.