Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 33

Thread: Clash of Clans API - a tutorial

  1. #11
    Fresh Spawn
    Join Date
    Aug 2016
    Posts
    1
    Quote Originally Posted by ufis View Post
    I have started to put together a tutorial on how to make a web page for your clan using the Clash of Clans API. This tutorial will be using PHP.

    What is the CoC API? : The Clash of Clans API provides near realtime access to game related data. In order to access the API, you need a developer account and a key for your application.

    Where do I find information on the API? : https://developer.clashofclans.com/ This is also where you register for your developer account and set up your key(s).

    The tutorial will cover 3 steps:
    1. Fetching game data from the API : link
    2. Displaying the data on the web : link
    3. Providing some style to the display : clan table ,
    @ufis, i has done following all three parts following this tutorial. And the results it's awesome, now i have one question. How to make clan level centering inside clan badge?


    Btw, thank's for who can answering my question..

  2. #12
    HTML Code:
    <style>
        clanlevel-badge{
            display: block;
            background: url('<?php echo $data["badgeUrls"]["medium"]; ?>') no-repeat center center;
        }
    </style>
    
    
    <td rowspan="11">
        <span class="clanlevel-text">Clan level : </span>
        <span class="clanlevel-badge"><?php echo $data["clanLevel"]; ?></span>
    </td>

    Something like this should work. Try to learn some CSS though. Putting everything in a table is not the right way to style your pages
    Last edited by thejeweler; August 23rd, 2016 at 11:20 PM.

  3. #13
    Hi Guys

    I observed many of us were looking for some tutorial to use Clash of Clans API and show data in Wordpress.
    Check out below three links:

    1) How to get access token for Clash of Clans API and other settings:
    http://www.clashersarena.com/clash-o...basics-part-1/

    2) How to show API data on a Wordpress Page
    http://www.clashersarena.com/clash-o...basics-part-2/

    3) How to store API data into a MySQL Table using Wordpress
    http://www.clashersarena.com/clash-o...basics-part-3/

    Hope this helps.
    Cheers !!!
    Raj (Co-Leader)
    Clan: RETURNOFTHEFALL
    TH9 | Level 109

  4. #14
    thank you so much

  5. #15
    Howdy - I'm trying to get data from the API using Google Sheets. Any advice on how to do it?

  6. #16
    Quote Originally Posted by pocketking View Post
    Howdy - I'm trying to get data from the API using Google Sheets. Any advice on how to do it?
    I am not aware of a way to call directly from the api to google sheets. however you can create a basic .php file that will hold your api token and link to your members list. From there you can pull the information into your google spreadsheet using the IMPORTHTML function.

    If you are reading this post within a couple of days of me writing it you can try it yourself with my php file just to see it work.
    however I do not intentd to keep that file for very much longer as I now run my website from a database instead of a spreadsheet.
    anyway... .. .

    paste the below function into cell A1 of an Empty google spreadsheet. and you will get the active roster of my Clan formatted in a way that you can manipulate.


    =IMPORTHTML("http://www.a1warmongerers.net/fromsupercell.php","table",0)
    Chance the Leader of #J8P8JCU
    http://www.A1Warmongerers.net

  7. #17
    New Bloke/Chick
    Join Date
    Jun 2015
    Posts
    46

    Post

    I've edited a bit your code to makes it work with players but now I have a problem.
    How can I get the achievment value ?
    We can get every value by doing echo $data['1']['2']
    But in the case of the achievements, the second is always the same...

    In the documentation,the achievements are not separated, so how can we take only one (like the Friend In Need one for exemple) ?:
    "achievements": [
    {
    "name": "string",
    "stars": 0,
    "value": 0,
    "target": 0,
    "completionInfo": "string"
    }
    Last edited by Arcree; April 2nd, 2017 at 07:22 PM.

  8. #18
    you can't just get one, you have to get them all. You can discard all of them except the one you want, where name is "Friend in Need".
    Wheel of Time. Check us out at www.discord.me/wotcoc for more information.

  9. #19
    New Bloke/Chick
    Join Date
    Jun 2015
    Posts
    46
    Quote Originally Posted by mahalleinir View Post
    you can't just get one, you have to get them all. You can discard all of them except the one you want, where name is "Friend in Need".
    I don't know how to get them all. I've tried a ton of thing but I don't get anything all the time :/

  10. #20
    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']
    Last edited by mahalleinir; April 4th, 2017 at 12:55 PM.
    Wheel of Time. Check us out at www.discord.me/wotcoc for more information.

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
  •