2017 © Pedro Peláez
 

library php-clash-of-clans

PHP wrapper for querying the Supercell Clash of Clans API

image

toniperic/php-clash-of-clans

PHP wrapper for querying the Supercell Clash of Clans API

  • Saturday, March 18, 2017
  • by toniperic
  • Repository
  • 10 Watchers
  • 36 Stars
  • 576 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 10 Forks
  • 3 Open issues
  • 1 Versions
  • 1 % Grown

The README.md

Clash of Clans API

Build Status Scrutinizer Code Quality, (*1)

Easily query Supercell's API for Clash of Clans data! This package uses official API. For more information, please visit https://developers.clashofclans.com, (*2)

This package is tested and working on PHP 5.5 and greater, including PHP 7.0!, (*3)

Do note that the API might change at any given moment, as there are no stable releases yet., (*4)

Requirements

For using this package, you need to obtain an API key at https://developer.clashofclans.com, (*5)

Installation

Using Composer

composer require toniperic/php-clash-of-clans=dev-master

Usage

When instantiating Client, you have to provide your API key:, (*6)

$client = new Client('API_KEY_HERE');

Clans

Refers to /clans endpoint from the official docs., (*7)

You can use any of the parameters specified in the official docs as keys, and the values as parameter values, likewise, (*8)

$client->getClans(['name' => 'Foo', 'minMembers' => 30]); // returns array of Clan objects

Tip: if you are only searching by clan name, you don't have to specify the array as parameter but just a simple string:, (*9)

$client->getClans('Foo'); // returns array of Clan objects

For all available parameters, please browse through the offical docs., (*10)

Get specific clan by tag

Refers to /clans/{clanTag} endpoint from the official docs., (*11)

It's very easy to use:, (*12)

$clan = $client->getClan('#2VP0J0VV'); // returns Clan object

$clan->name(); // "Hattrickers"
$clan->level(); // 8
$clan->warWins(); // 168

For more available methods, visit ClashOfClans\Api\Clan\Clan class., (*13)

Getting leader info

$leader = $clan->memberList()->leader(); // returns Player
$leader->name(); // "VanSilent"
$leader->donations(); // 3451
$leader->expLevel(); // 118
$leader->trophies(); // 2548

For more available methods, visit ClashOfClans\Api\Clan\Player class., (*14)

Getting co-leaders and elders

$coLeaders = $clan->memberList()->coLeaders(); // array of Player objects
$elders = $clan->memberList()->elders(); // array of Player objects

Leagues

Refers to /leagues endpoint from the official docs., (*15)

$leagues = $client->getLeagues(); // returns array of League objects

$leagues[0]->id(); // 29000001
$leagues[0]->name(); // Bronze League III

Locations

Refers to /locations endpoint from the official docs., (*16)

Getting all available locations is pretty easy:, (*17)

$client->getLocations(); // returns array of Location objects

Get specific location by ID

Refers to /locations/{locationId} endpoint from the official docs., (*18)

$location = $client->getLocation(32000066); // returns Location object

$location->name(); // Croatia
$location->countryCode(); // HR
$location->isCountry(); // true

Get rankings for specific location

Refers to /locations/{locationId}/rankings/{rankingId} endpoint from the official docs., (*19)

$rankings = $client->getRankingsForLocation($locationId, 'clans'); // returns array of Clan objects

// top clan
$rankings[0]->name(); // Foobar
$rankings[0]->trophies(); // 47846

Instead of 'clans', as the second parameter you can also pass string players which will return array of Player objects., (*20)

The Versions

18/03 2017

dev-master

9999999-dev

PHP wrapper for querying the Supercell Clash of Clans API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Toni Peric