<?php require_once './ClashAPI/API.class.php'; $api = new ClashOfClans(); $location = new CoC_Location(0); $location->setLocationByName("Germany"); $params = array('name' => 'fox', 'minMembers' => 25, 'locationId' => $location->getLocationId()); $clans = $api->searchClan($params); echo "All Clans that meet the following criteria: name => fox, minMembers => 25, locationId = [Germany's Location ID] <br/>" . PHP_EOL; foreach ($clans->items as $clan) { $clan = new CoC_Clan($clan); echo "<img src=\"" . $clan->getBadgeUrl("small") . "\"> " . $clan->getName() . "<br/>" . PHP_EOL; }
<?php require_once "./ClashAPI/API.class.php"; $api = new ClashOfClans(); $germany = new CoC_Location(0); //setting this to 0 because we set the Location using "setLocationByName" $germany->setLocationByName("Germany"); //$germany->setLocationByCode("DE"); //works as well $results = $api->getRankList($germany->getLocationId(), true); //get the clan ranklist for the given location. for ($i = 0; $i < 100; $i++) { $clan = new CoC_Clan($results->items[$i], false); //updated constructor allows passing clan-classes returned from getRankList if the second parameter is set to false echo $clan->getName() . "<br/>"; }
<?php require_once "./ClashAPI/API.class.php"; $api = new ClashOfClans(); if ($api->isWarlogPublic("#22UCCU0J")) { $warlog = new CoC_Warlog($api->getWarlog("#22UCCU0J", array("limit" => 10))); for ($i = 0; $i < $warlog->getLogEntryAmount(); $i++) { $logEntry = new CoC_LogEntry($warlog->getLogEntryByIndex($i)); if ($logEntry->getResult() == "win") { echo '<font color="green">'; } else { if ($logEntry->getResult() == "lose") { echo '<font color="red">'; } else { if ($logEntry->getResult() == "draw") { echo '<font color="black">'; } } } echo $logEntry->getClanName() . " " . $logEntry->getClanStars() . " - " . $logEntry->getOpponentStars() . " " . $logEntry->getOpponentName() . " </font><br/>"; } } else { echo "This clan's warlog isn't public, sorry."; }