Getting started with Clash of Clans API
Go to https://developer.clashofclans.com/. Register and set up your token.
Demo 01 : Getting data from Clash of Clans API source in action
  1. Replace <CLANTAG> with your clan tag. Find this in game on your clan screen.
  2. Replace <APITOKEN> with with your API token.
  3. $url can be any of the urls specified by API documentation.
  4. More reading on: curl_init, curl_setopt, curl_exec, json_decode
Demo 02 : Displaying the data source in action
  1. Remove php header function as we are now using HTML to set the charset
  2. Remove var_dump function as we are now using HTML to display the results
  3. Add a way to display any error with fetching data from API
  4. Add the clan name to the <title> tag
  5. Add the clan data (as defined in $data variable) to a set <table>
  6. Loop through the member list (as defined by $members) and add to <tr> tag within a <table> for members of the clan
  7. More reading on: php arrays, isset, echo, foreach, HTML5
Demo 03 : Fixing the display source in action
...
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
<?php
$clantag 
"<CLANTAG>";

$token "<APITOKEN>";

$url "https://api.clashofclans.com/v1/clans/" urlencode($clantag);

$ch curl_init($url);

$headr = array();
$headr[] = "Accept: application/json";
$headr[] = "Authorization: Bearer ".$token;

curl_setopt($chCURLOPT_HTTPHEADER$headr);
curl_setopt($chCURLOPT_SSL_VERIFYHOSTfalse);
curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
curl_setopt($chCURLOPT_RETURNTRANSFER1); 

$res curl_exec($ch);
$data json_decode($restrue);
curl_close($ch);

if (isset(
$data["reason"])) {
  
$errormsg true;
}

$members $data["memberList"];

?>
  <title><?php echo $data["name"]; ?></title>
</head>
<body>
<?php
  
if (isset($errormsg)) {
    echo 
"<p>""Failed: "$data["reason"], " : ", isset($data["message"]) ? $data["message"] : """</p></body></html>";
    exit;
  }
?>
  <table border="1">
    <tr>
      <td rowspan="11">Clan level : <?php echo $data["clanLevel"]; ?><br/><img src="<?php echo $data["badgeUrls"]["medium"]; ?>" alt="<?php echo $data["name"]; ?>"/></td>
      <td><?php echo $data["name"]; ?></td><td><?php echo $data["tag"]; ?></td>
      <td rowspan="11"><?php echo $data["description"]; ?></td>
    </tr>
    <tr>
      <td>Total points</td><td><?php echo $data["clanPoints"]; ?></td>
    </tr>
    <tr>
      <td>Wars won</td><td><?php echo $data["warWins"]; ?></td>
    </tr>
    <tr>
      <td>War win streak</td><td><?php echo $data["warWinStreak"]; ?></td>
    </tr>
    <tr>
      <td>Wars drawn</td><td><?php echo $data["warTies"]; ?></td>
    </tr>
    <tr>
      <td>Wars lost</td><td><?php echo $data["warLosses"]; ?></td>
    </tr>
    <tr>
      <td>Members</td><td><?php echo $data["members"]; ?>/50</td>
    </tr>
    <tr>
      <td>Type</td><td><?php echo $data["type"]; ?></td>
    </tr>
    <tr>
      <td>Required trophies</td><td><?php echo $data["requiredTrophies"]; ?></td>
    </tr>
    <tr>
      <td>War frequency</td><td><?php echo $data["warFrequency"]; ?></td>
    </tr>
    <tr>
      <td>Clan location</td><td><?php echo $data["location"]["name"]; ?></td>
    </tr>
  </table>
  <table border="1">
<?php
  
foreach ($members as $member) {
?>
    <tr>
      <td><?php echo $member["clanRank"], "("$member["previousClanRank"], ")"?></td>
      <td><img src="<?php echo $member["league"]["iconUrls"]["tiny"]; ?>" alt="<?php echo $member["league"]["name"]; ?>"/></td>
      <td><?php echo $member["expLevel"]; ?></td>
      <td><?php echo "<b>"$member["name"], "</b><br/>"$member["role"]; ?></td>
      <td>Donated:<br/><?php echo $member["donations"]; ?></td>
      <td>Received:<br/><?php echo $member["donationsReceived"]; ?></td>
      <td><?php echo $member["trophies"]; ?></td>
    </tr>
<?php
  
}
?>
  </table>
</body>
</html>