PHP code example of chypriote / pandascore-php

1. Go to this page and download the library: Download chypriote/pandascore-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

chypriote / pandascore-php example snippets


//  Include all DIR__  . "/vendor/autoload.php";

use PandaScoreAPI\PandaScoreAPI;

//  Initialize the library
$api = new PandaScoreAPI([
	//  Your API key, you can get one at https://pandascore.co/settings
	PandaScoreAPI::SET_TOKEN    => 'YOUR_PANDASCORE_TOKEN',
	// If you need to use a game specific API, you initialize it at launch
	PandascoreAPI::USE_LEAGUE_OF_LEGENDS => true,
]);

//  And now you are ready to rock!
$ch = $api->leagues->getLeague(61);
// Get only the datas from the games you need
$lolch = $api->lol->tournaments->listTournaments();

//  ...initialization...

//  this fetches the summoner data and returns SummonerDto object
$league = $api->getLeague(4213);

echo $league->id;             //  4213
echo $league->name;           //  LVP SLO
echo $league->slug;           //  league-of-legends-lvp-slo

print_r($league->getData());  //  Or array of all the data
/* Array
 * (
 *     [id] => 4213
 *     [slug] => league-of-legends-lvp-slo
 *     [name] => LVP SLO
 * )
 */
shell
root@localhost:~/src/PandaScoreAPI# php PandaScoreAPICLI.php getLeague 61 --config ~/PandaScoreAPI_Config.json