Page 6 of 6 FirstFirst ... 456
Results 51 to 58 of 58

Thread: API output

  1. #51
    Junior Member
    Join Date
    Oct 2015
    Posts
    52
    Quote Originally Posted by LordWombat View Post
    How can I let it display if a war is more than 1 month ago?

    In the moment it always starts again one day or three days ago. But not a month ago

    Now it is so, if a war is longer than 30/31 days over it starts again with 1 day ago and so on ......
    Hello!

    Correct, %d is reflecting the number of days in the first month of the year...
    Try replacing the %d by %z in the formating (you should then go up to 365 before starting over to one)

  2. #52
    Quote Originally Posted by OriOn86 View Post
    Hello!

    Correct, %d is reflecting the number of days in the first month of the year...
    Try replacing the %d by %z in the formating (you should then go up to 365 before starting over to one)
    Hi and Merry X-mas

    sorry, this does not work for me

    when I set the %z in the first row

    PHP Code:
    $endTime $warlog["endTime"];

    $DateEnd datetime::createFromFormat("Ymd\THis\.u\Z",$endTime);
    $DateNow = new datetime();
    $interval $DateEnd->diff($DateNow);

    if (
    $interval->format("%z") < 1) {
        if ((int)
    $interval->format("%h") == 1) {
            echo 
    $interval->format("%h") . " hour ago <br />";
        } else {
            echo 
    $interval->format("%h") . " hours ago <br />";
        }
    } else {
        if ((int)
    $interval->format("%d") == 1) {
            echo 
    $interval->format("%d") . " day ago <br />";
        } else {
            echo 
    $interval->format("%d") . " days ago <br />";
        }

    it shows me only the hours ago

    when I use the %z at
    PHP Code:
    } else {
        if ((int)
    $interval->format("%z") == 1) { 
    nothing changed. It shows me 4 day ago, - 29 days ago and starts with 2 days ago ......
    my API projekt : my Clan Projekt

  3. #53

    Achievments in german output

    I´m translating the english output into german

    PHP Code:
    // achiev names
    $achievname $achievement->name;
    if (
    $achievname == 'Bigger Coffers'){$achievname str_replace('Bigger Coffers''Gro&szlig;e Kisten'$achievname);}
    if (
    $achievname == 'Get those Goblins!'){$achievname str_replace('Get those Goblins!''Schnappt die Koboldde!'$achievname);}
    if (
    $achievname == 'Bigger & Better'){$achievname 'Gr&ouml;&szlig;er und besser';}

    // achiev infos
    $achievinfo $achievement->info;
    if (
    $achievinfo != 'Upgrade a Gold Storage to level 2'){$achievinfo str_replace('Upgrade a Gold Storage to level''Verbessere ein Goldlager auf Level'$achievinfo);}
    if (
    $achievinfo != 'Win 150 stars on the Campaign Map'){$achievinfo str_replace('Win  stars on the Campaign Map''Gewinne  Sterne auf der Kampagnenkarte'$achievinfo);}
    if (
    $achievinfo != 'Upgrade Town Hall to level 3'){$achievinfo str_replace('Upgrade Town Hall to level''Verbessere das Rathaus auf Level'$achievinfo);}

    // achiev completinfos
    $achievcomplet $achievement->completionInfo;
    if (
    $achievcomplet != 'Highest Gold Storage level : 11'){$achievcomplet str_replace('Highest Gold Storage level''H&ouml;chstes Goldlager-Level'$achievcomplet);} 
    with the numbers at the end from the text it works verry well.
    but with the numbers at the second or third or forth poistion I have no luck

    how can I use the
    PHP Code:
    str_replace 
    on this ?
    my API projekt : my Clan Projekt

  4. #54
    Quote Originally Posted by LordWombat View Post
    next problem .....

    i know the way to show a icon for each Troopname , Spells, and Hero

    PHP Code:
    $result file_get_contents($urlnullstream_context_create($opts));
    $response json_decode($result,true);

    foreach(
    $response['troops'] as $item) {
        
    $playertroopname $item['name'];
        
    $playertrooplevel $item['level'];
        
    $playertroopmlevel $item['maxLevel'];
        }
    if (
    $playertroopname Archer){$playertroopname "$troopArcher";}
    elseif (
    $playertroopname Goblin){$playertroopname "$troopGoblin";}
    elseif (
    $playertroopname Giant){$playertroopname "$troopGiant";}
    elseif (
    $playertroopname Wall.' '.Breaker){$playertroopname "$troopWallBreaker";}
    elseif (
    $playertroopname Balloon){$playertroopname "$troopBalloon";}
    elseif (
    $playertroopname Wizard){$playertroopname "$troopWizard";}


    $troopArcher "../images/troops/Archer.png";
    $troopGiant "../images/troops/Giant.png";
    $troopGoblin "../images/troops/Goblin.png"
    How can I show the Icon for each troop what the player has reached?

    PHP Code:
                        echo '<div style="position:absolute;top:304px;left:230px; color:#FFEDB5; text-shadow: 3px 4px 5px rgba(0,0,0, 1); z-index:2; font-family:supercell; font-size:20px">';
                          echo 
    '<img src="'.$troopArcher.'" height="48" width="48"</img>';
                                            echo 
    '</div>';

                        echo 
    '<div style="position:absolute;top:304px;left:278px; color:#FFEDB5; text-shadow: 3px 4px 5px rgba(0,0,0, 1); z-index:2; font-family:supercell; font-size:20px">';
                          echo 
    '<img src="'.$troopGiant.'" height="48" width="48"</img>';
                                            echo 
    '</div>';

                        echo 
    '<div style="position:absolute;top:304px;left:328px; color:#FFEDB5; text-shadow: 3px 4px 5px rgba(0,0,0, 1); z-index:2; font-family:supercell; font-size:20px">';
                          echo 
    '<img src="'.$troopGoblin.'" height="48" width="48"</img>';
                                            echo 
    '</div>';

                        echo 
    '<div style="position:absolute;top:304px;left:378px; color:#FFEDB5; text-shadow: 3px 4px 5px rgba(0,0,0, 1); z-index:2; font-family:supercell; font-size:20px">';
                          echo 
    '<img src="'.$troopWallBreaker.'" height="48" width="48"</img>';
                                            echo 
    '</div>'
    With this code up here always the icon is displayed to me. Even if the player has not yet reached a troop

    I have it tried with
    PHP Code:
    if ($playertroopname Archer
    and
    PHP Code:
    elseif ($playertroopname Goblin
    when I use the if and elseif only the archer will be shown

    How can I show the level for each troop name?
    Hi,
    beware of the usage of '=' , in PHP it means assignment. If you want to compare, you must use '==' instead.
    This is why you always get an Archer.
    So change it to:
    if ($playertroopname == Archer){$playertroopname = "$troopArcher";}
    elseif ($playertroopname == Goblin){$playertroopname = "$troopGoblin";}

    and so on.

  5. #55
    Senior Member
    Join Date
    Feb 2016
    Posts
    206
    How can I create a top 5 with achievements? Ex top 5 war stars, top 5 gold grab ecc ecc..
    I can't access to the achievements with a loop

    Sorry for my english!
    Profile aRtik #C8P2LG8Q | Clan HELL'S ANGELS #8POUPPQ9|BKAQGW 60/65/35 | All time best 6175|

  6. #56
    You have to gather it all in an array and sort it or, what I did, gather it all in a database and then do a database query to your liking.
    The benefits of the database is much faster response. The array means you have to incorporate your JSON query into the same process which adds the most time for your information to load.
    Wheel of Time. Check us out at www.discord.me/wotcoc for more information.

  7. #57
    Quote Originally Posted by aRtikMania View Post
    How can I create a top 5 with achievements? Ex top 5 war stars, top 5 gold grab ecc ecc..
    Quote Originally Posted by mahalleinir View Post
    You have to gather it all in an array and sort it or, what I did, gather it all in a database and then do a database query to your liking.
    The benefits of the database is much faster response. The array means you have to incorporate your JSON query into the same process which adds the most time for your information to load.
    Hi guys!

    I'm hoping to achieve the same as the person on top, so I'm also looking for a script to compare achievements (top 5 lists on certain categories) on my clans website.

    Unfortunately my skills with PHP are almost par to zero, so I can't write the code from the ground up myself. Is there any code template or guide up anywhere, that would help me to gather the necessary data of my clan members achievements from CoC API to mysql table (or somewhere else)?

    Cheers! Hope someone can help me with this!

  8. #58
    well, there are a couple of threads here that have started the groundwork in starting a website and there are a few templated packages out. If you aren't familiar with PHP, people have written code in PERL, some in java, I believe, some as a wordpress addon. I will tell you that from my experience you need a system that ties into a database back end for backup. Without this, your website is going to be really, really slow.
    Wheel of Time. Check us out at www.discord.me/wotcoc for more information.

Posting Permissions

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