Skip to content

castronet/clash-royale-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 

Repository files navigation

clash-royale-php Packagist GitHub release Total Downloads

THE UNOFFICIAL PHP Clash Royale Wrapper

INDEX

  1. INFO
  2. DOCUMENTATION
  3. CONTRIBUTING
  4. REQUIREMENTS
  5. INSTALLATION
  6. TOKEN
  7. UPCOMING FEATURES
  8. METHODS
    1. ALL METHODS
    2. getPlayer()
    3. getClan()
    4. getTop()
    5. clanSearch

INFO

This work with the back-end of this page Clash Royale API

DOCUMENTATION

All the document can be found in this web Royale API Docs.

We will make other specific docs in the wiki section for this wrapper and how it works ( comming soon )

CONTRIBUTING

You can contribute to this project opening a new issue with your ideas or you can contact with me by Telegram

REQUIREMENTS

PHP 5.6 or greater

Composer

INSTALLATION

In the root of your project (the same path wich contain the composer file) enter

 composer install

to install the library or use

composer require firegore2/clash-royale-php

to instal in your own project.

TOKEN

You need a developer token to use the API.

This are the steps to obtain it:

  1. Go to the discord server of the API
  2. Go to the #developer-key channel.
  3. Type ?crapikey get
  4. The bot will send you a DM (direct message) with your key.

UPCOMING FEATURES

Multi threading

Auto generated documents

Auto generated database (SQL or SQLlite)

Cron

METHODS

See examples folder for more information

ALL METHODS

@method getPlayer([ player0,player1,player2,player3,...],[ Optional keys0,keys1,keys2,keys3,...],[ Optional exclude0,exclude1,exclude2,exclude3,...]) 
@method getPlayerBattle([ player0,player1,player2,player3,...],[ Optional keys0,keys1,keys2,keys3,...],[ Optional exclude0,exclude1,exclude2,exclude3,...]) 
@method getPlayerChest([ player0,player1,player2,player3,...],[ Optional keys0,keys1,keys2,keys3,...],[ Optional exclude0,exclude1,exclude2,exclude3,...]) 
@method getClanSearch( Optional name default = '' , Optional score default = 0 , Optional minMembers default = 0 , Optional maxMembers default = 50 ) 
@method getClanTracking([],['includeKey1','includeKey2','includeKey3',...],['excludeKey1','excludeKey2','excludeKey3',...]) 
@method getClan([ clan0,clan1,clan2,clan3,...],[ Optional keys0,keys1,keys2,keys3,...],[ Optional exclude0,exclude1,exclude2,exclude3,...]) 
@method getClanBattle([ clan0,clan1,clan2,clan3,...],[ Optional keys0,keys1,keys2,keys3,...],[ Optional exclude0,exclude1,exclude2,exclude3,...], Optional type default = '' ) 
@method getClanWar([ clan0,clan1,clan2,clan3,...],[ Optional keys0,keys1,keys2,keys3,...],[ Optional exclude0,exclude1,exclude2,exclude3,...]) 
@method getClanWarlog([ clan0,clan1,clan2,clan3,...],[ Optional keys0,keys1,keys2,keys3,...],[ Optional exclude0,exclude1,exclude2,exclude3,...]) 
@method getClanHistory([','','',...],['includeKey1','includeKey2','includeKey3',...],['excludeKey1','excludeKey2','excludeKey3',...]) 
@method getClanHistoryWeekly([','','',...],['includeKey1','includeKey2','includeKey3',...],['excludeKey1','excludeKey2','excludeKey3',...]) 
@method getClanTracking([','','',...],['includeKey1','includeKey2','includeKey3',...],['excludeKey1','excludeKey2','excludeKey3',...]) 
@method getClanTrack([','','',...],['includeKey1','includeKey2','includeKey3',...],['excludeKey1','excludeKey2','excludeKey3',...]) 
@method getTournamentOpen([],['includeKey1','includeKey2','includeKey3',...],['excludeKey1','excludeKey2','excludeKey3',...]) 
@method getTournamentKnown([],['includeKey1','includeKey2','includeKey3',...],['excludeKey1','excludeKey2','excludeKey3',...]) 
@method getTournamentSearch([],['includeKey1','includeKey2','includeKey3',...],['excludeKey1','excludeKey2','excludeKey3',...]) 
@method getTournament([','','',...],['includeKey1','includeKey2','includeKey3',...],['excludeKey1','excludeKey2','excludeKey3',...]) 
@method getTopClan(['CountryCode'],['includeKey1','includeKey2','includeKey3',...],['excludeKey1','excludeKey2','excludeKey3',...]) 
@method getTopPlayer( Optional location default = '' ) 
@method getPopularClan([],['includeKey1','includeKey2','includeKey3',...],['excludeKey1','excludeKey2','excludeKey3',...]) 
@method getPopularPlayer([],['includeKey1','includeKey2','includeKey3',...],['excludeKey1','excludeKey2','excludeKey3',...]) 
@method getPopularTournament([],['includeKey1','includeKey2','includeKey3',...],['excludeKey1','excludeKey2','excludeKey3',...]) 
@method getPopularDeck([],['includeKey1','includeKey2','includeKey3',...],['excludeKey1','excludeKey2','excludeKey3',...]) 
@method getConstant() 
@method getAuthStats() 
@method getVersion([],['includeKey1','includeKey2','includeKey3',...],['excludeKey1','excludeKey2','excludeKey3',...]) 
@method getHealth() 
@method getStatus([],['includeKey1','includeKey2','includeKey3',...],['excludeKey1','excludeKey2','excludeKey3',...]) 
@method getEndpoints() 

getPlayer()

<?php
use CR\Api;
require 'vendor/autoload.php';
   /**
   * Return 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);
}

getClan()

<?php
use CR\Api;
require 'vendor/autoload.php';
/**
 * Return all the information about the given clan tag
 * @method getClan
 * @param  array  $clan       Array with the tag of the clans
 * @return Clan[]         Array of Clan Objects if given more than one profile, else return one Clan Object
 */
$token = "YOUR_TOKEN";
$api = new Api($token);
try{
 $clans = $api->getClan(["clan_tag1","clan_tag2"]);
 d($clans); //This display the Array of Clan objects
}
catch(Exception $e){
 d($e);
}

getTop()

<?php
use CR\Api;
require 'vendor/autoload.php';

/**
 * Return all 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);
}

clanSearch

<?php
ini_set('max_execution_time', 3000);
use CR\Api;
require 'vendor/autoload.php';

$token = "YOUR_TOKEN";
$api = new Api($token);

try {
  
  /**
   * 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 required score to enter the clan
     * @method    int                 getDonations()          Returns the total donations per week of the clan
     * @method    AllianceBadge       getBadge()              Returns the AllianceBadge Object of the clan
     * @method    Location            getLocation()           Returns the Location Object of the clan
     */
    $tag = $clanSearch->getTag();
    $name = $clanSearch->getName();
    $type = $clanSearch->getType();
    $score = $clanSearch->getScore();
    $memberCount = $clanSearch->getMemberCount();
    $requiredScore = $clanSearch->getRequiredScore();
    $donations = $clanSearch->getDonations();

    /**
     * AlianceBadge object
     *
     *
     * @method    string              getName()               Returns the name of the badge
     * @method    string              getCategory()           Returns the category name of the badge
     * @method    int                 getId()                 Returns the id of the badge
     * @method    string              getImage()              Returns the image url of the badge
     *
     *
     */
    $badge = $clanSearch->getBadge();
    $name = $badge->getName();
    $category = $badge->getCategory();
    $id = $badge->getId();
    $image = $badge->getImage();


    /**
     *  Location object
     * @method    string              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,
      $requiredScore,
      $donations,
      $badge,
      $name,
      $category,
      $id,
      $image,
      $location,
      $country,
      $continent,
      $countryCode,
      $continentCode
    );
  }
} catch (\Exception $e) {
  d($e);
}

About

THE UNOFFICIAL PHP Clash Royale Wrapper

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%