Advertisement
nathan66669

Clash API - Clan

Feb 13th, 2018
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.80 KB | None | 0 0
  1.  
  2. <?php
  3.  
  4. header("Content-Type: application/json");
  5.  
  6. if (!isset($_GET["key"])) {
  7.     echo '{"access_denied": "No "key" field!"}';
  8.     exit();
  9. }
  10.  
  11. if ($_GET["key"] == "{my key}") {
  12.     if (isset($_GET["tag"])) {
  13.         $access_token = "{my token}";
  14.         $headers = array("Authorization: Bearer " . $access_token);
  15.  
  16.         // Initiate connection with API
  17.         $ch = curl_init("https://api.clashofclans.com/v1/clans/%23" . $_GET["tag"] . "/members");
  18.         // Set the Authorization header
  19.         curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  20.         // Execute the request (which also echo's it to the user)
  21.         curl_exec($ch);
  22.         // Close request
  23.         curl_close($ch);
  24.     } else {
  25.         echo '{"error": "No "tag" field!"}';
  26.     }
  27. } else {
  28.     echo '{"access_denied": "Wrong "key" field!"}';
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement