PHP code example of firegore2 / clash-royale-php

1. Go to this page and download the library: Download firegore2/clash-royale-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/ */

    

firegore2 / clash-royale-php example snippets


composer 


use CR\Api;
n all the information about the given users tag
   * @method getPlayer
   * @param  array     $player          Array with the id of the profiles
   * @param  array     $keys            Array with the exact parameters to request
   * @param  array     $exclude         Array with the exact parameters to exclude in the request
   * @return Player[]                   Array of Player Objects if given more than one profile, else return one Player Object
   */
$token = "YOUR_TOKEN";
$api = new Api($token);
try{
 $player = $api->getPlayer(["JSDFS45","ASDAD123"]);
 d($player); //This display the array with Player objects
}
catch(Exception $e){
 d($e);
}



use CR\Api;
l information about the top players or clans
 * @method getTop
 * @param  array  $top  Array with values "players" or/and "clans"
 * @return array        Array with key of respectives top type ("players" or "clans") and with their values an array with "lastUpdate" 
 * of the top list and the respective array with the respective objects type ("players" = array CR\Objects\Profile)
 */

$token = "YOUR_TOKEN";
$api = new Api($token);
try{
 $tops = $api->getTop(["players","clans"]);
 d($tops); //This display the array with Profile objects
}
catch(Exception $e){
 d($e);
}



ini_set('max_execution_time', 3000);
use CR\Api;

  
  /**
   * Search clans by their attributes
   * @method clanSearch
   * @param  string           $name                 (Optional)Clan name text search.
   * @param  int              $score                (Optional) Minimum clan score.
   * @param  int              $minMembers           (Optional) Minimum number of members. 0-50
   * @param  int              $maxMembers           (Optional) Maximum number of members. 0-50
   * @return ClanSearch[]     $clanSearch           Returns an array of Clan objects that match the search parameters
   */

  $clansSearch = $api->clanSearch("INFRAMUNDO",35140,44,46);

  foreach ($clansSearch as $clanSearch) {

    /**
     * ClanSearch object
     *
     * @method    string              getTag()                Returns the tag of the clan
     * @method    string              getName()               Returns the name of the clan
     * @method    string              getType()               Returns the admission type of the clan
     * @method    int                 getScore()              Returns the score of the clan
     * @method    int                 getMemberCount()        Returns the members number of the clan
     * @method    int                 getRequiredScore()      Returns the            getName()               Returns the name of the location.
     * @method    bool                getIsCountry()          Returns true if the location is a country. otherwise returns false.
     * @method    string              getCode()               Returns the country/continent code
     *
     *
     * @method    string              getContinent()          Returns the continent name
     * @method    string              getContinentCod()       Returns the continent code
     * @method    string              getCountry()            Returns the country name
     * @method    string              getCountryCode()        Returns the country code
     */
    $location = $clanSearch->getLocation();
    $country = $location->getCountry();
    $continent = $location->getContinent();
    $countryCode = $location->getCountryCode();
    $continentCode = $location->getContinentCode();

    d(
      $clanSearch,
      $tag,
      $name,
      $type,
      $score,
      $memberCount,
      $