This is a wrapper for SuperCell's official Clash Of Clans-API located at https://developer.clashofclans.com/#/ and best to use with Discord PHP Wrapper for interaction with Clash API.
You have to create an account on their website and provide credential in the script. The script will auto create an key.
- Trying to cover everything of ClashOfClans API.
- Email/password login removes the stress of managing tokens
- Optimised for speed, memory and performance
PHP 7 or higher with cURL support.
$start = new ClashAPILogin();
$login = $start->login("youremail@gmail.com","yourpass");
echo $login; // this will return the api key generated
$api = new ClashOfClans();
$results = $api->searchClanByName("The Order"); //returns an array containing all search results
$clan = new CoC_Clan($results->items[0]); //gets the first result from the array
$clan = new CoC_Clan("#2PP");
$clan->getName(); //returns clan name
$clan->getLevel(); //returns level of clan
<?php
require_once "./API/API.class.php";
require_once "./API/Login.class.php";
include __DIR__.'/vendor/autoload.php';
use Discord\Discord;
use Discord\Parts\Channel\Message;
use Psr\Http\Message\ResponseInterface;
use React\EventLoop\Factory;
use React\Http\Browser;
$discord = new Discord([
'token' => 'token',
]);
$discord->on('ready', function ($discord) {
echo "Bot is ready!", PHP_EOL;
$start = new ClashAPILogin();
//$login = $start->login($dev_email,$dev_password);
$login = $start->login("",""); //insert your credentials
// Listen for messages.
$discord->on('message', function (Message $message, Discord $discord) {
if($message->content == 'clan' && ! $message->author->bot){
$foxforce = new CoC_Clan("#2PP");
$message->reply($foxforce->getName());
}
});
});
$discord->run();
?>
Contributing is fantastic and much welcomed! If you have an issue, feel free to open an issue and start working on it.
Reach me on discord my username is Shavy#0504
This content is not affiliated with, endorsed, sponsored, or specifically approved by Supercell and Supercell is not responsible for it. For more information see Supercell's Fan Content Policy.