Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 33

Thread: Clash of Clans API - a tutorial

  1. #21
    New Bloke/Chick
    Join Date
    Jun 2015
    Posts
    46
    Quote Originally Posted by mahalleinir View Post
    It may be related to how you are handling the structure. What language are you using?
    Here is what the structure looks like for a player: http://www.ufaclash.co/bank3.php

    Maybe what you need is echo $data['14']['value']
    I
    HTML Code:
    $tag = $_GET['tag'];    
    $tag = substr_replace($tag,"#",0,0);            
    $token = "token";
                
    $url = "https://api.clashofclans.com/v1/players/" . urlencode($tag);
        
    $ch = curl_init($url);            
    $headr = array();    
    $headr[] = "Accept: application/json";    
    $headr[] = "Authorization: Bearer ".$token;
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headr);    
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);    
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);    
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    $res = curl_exec($ch);    $data = json_decode($res, true);    
    curl_close($ch);    ?>
    <h3>    
    <?php    
    echo $data['name'];    ?>
    (    
    <?php    
    echo $data['tag'];    ?>
    )
    </h3>
    I use something like that .
    So I don't know how to get achievements (echo $data['14']['value']; )
    Last edited by Arcree; April 4th, 2017 at 05:12 PM.

  2. #22
    Quote Originally Posted by Arcree View Post
    I
    HTML Code:
    $tag = $_GET['tag'];    
    $tag = substr_replace($tag,"#",0,0);            
    $token = "token";
                
    $url = "https://api.clashofclans.com/v1/players/" . urlencode($tag);
        
    $ch = curl_init($url);            
    $headr = array();    
    $headr[] = "Accept: application/json";    
    $headr[] = "Authorization: Bearer ".$token;
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headr);    
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);    
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);    
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    $res = curl_exec($ch);    $data = json_decode($res, true);    
    curl_close($ch);    ?>
    <h3>    
    <?php    
    echo $data['name'];    ?>
    (    
    <?php    
    echo $data['tag'];    ?>
    )
    </h3>
    I use something like that .
    So I don't know how to get achievements (echo $data['14']['value']; )
    <?php
    foreach ($data['achievements'] as $achievement)
    {
    print $achievement['name'];
    print "<br>";
    print $achievement['value'];
    print "<br>";
    print $achievement['stars'];
    print "<br>";
    }
    ?>
    do the same for troops, spells, heroes
    Wheel of Time. Check us out at www.discord.me/wotcoc for more information.

  3. #23
    Fresh Spawn
    Join Date
    Dec 2013
    Posts
    6
    You should use htmlspecialchars on the clan name and description, or else risk a clan whose name is <!--, or a malicious clan putting javascript into their clan description, breaking stuff on your site.

  4. #24
    Junior Member
    Join Date
    May 2018
    Posts
    58
    Thanks for the totorial

  5. #25
    Hey,

    I have a problem, I am not very familiar with php so i don't know what to do. Here is what it says when I try to load the page: Notice: Undefined index: memberList in /opt/lampp/htdocs/clashofclans/index.php on line 31
    Failed: notFound :

    Thanks.

  6. #26
    Fresh Spawn
    Join Date
    Feb 2019
    Posts
    2

    data integration with google spreadsheets

    I can unify data from players and clans in a single request from the link and my key? I would like to know if I only get the link integrated with my key so I could use the data in google spreadsheets

  7. #27

    Join Date
    Sep 2014
    Location
    Digging another tunnel in the data mine
    Posts
    6,614
    Quote Originally Posted by CronusDP View Post
    I can unify data from players and clans in a single request from the link and my key?
    No, not without something else in the middle making multiple requests to SC. Although the clan list does contain some player data.

    I would like to know if I only get the link integrated with my key so I could use the data in google spreadsheets
    But, I doubt you could run it from google spreadsheets anyway. You have to register a fixed IP address that you will be accessing the SC API from. I doubt you can predict where google will send their requests to SC from, and even if it's consistent for a while it could change at any time
    Various data posts: Who plays what? CWL data 1 (stars), 2 (3* rates), 3 (rosters), 4 (start times and other) Data at end of old Legends And (non-data) how max bases are ordered in war
    --------------------
    Forum cup organiser. The forum cup discord server is: https://discord.gg/KEUxV2e

  8. #28
    Fresh Spawn
    Join Date
    Feb 2019
    Posts
    2
    How do I view a player's clan history?

  9. #29
    Junior Member
    Join Date
    Jan 2017
    Posts
    70
    We need one for Java!
    TH10+? Living in your mom's basement? Quit school at 15, or fired? We want you. Bring some beer🍻 #20PVJGRQ2 https://discord.gg/rwXmQG7

  10. #30
    > How do I view a player's clan history?


    What do you mean with "player's clan history" ?
    Last edited by bodiccea; March 23rd, 2019 at 07:47 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •