Results 1 to 7 of 7

Thread: when $clantag include number then error 500?

  1. #1

    Question when $clantag include number then error 500?

    Code:
    $clantag = "#Y988UYVV";
    https://www.hwj6.cn/clan.php error 500,

    but

    Code:
    $clantag = "#YPVJLPPR";
    https://www.hwj6.cn/clan1.php is fine

    the other code and token is same
    Last edited by 943680363; May 6th, 2018 at 03:00 AM.

  2. #2
    OnyxDS's Avatar
    Join Date
    Sep 2014
    Location
    Brexit Island
    Posts
    5,683
    It must just have been a glitch, it works fine for me:

    Code:
    {{
      "tag": "#Y988UYVV",
      "name": "落寞的枯叶蝶",
      "type": "open",
      "description": "秋季的风带来凋零的叶,冬季的雪遮盖忧伤的蝶。             部落群号:513640610不要伸手党是最低要求。请尊重每一个部落成员,不愿有太多规则束缚,不过是向往自由与公平.另  首领微信号vsk840217841 分部 话亦博弈",
      "location": {
        "id": 32000056,
        "name": "China",
        "isCountry": true,
        "countryCode": "CN"
      },
      "badgeUrls": {
        "small": "https://api-assets.clashofclans.com/badges/70/xNJu5T7tzofI4dqzjZ8LdRMQ6sDDeNlpiFS2TnjPxAE.png",
        "large": "https://api-assets.clashofclans.com/badges/512/xNJu5T7tzofI4dqzjZ8LdRMQ6sDDeNlpiFS2TnjPxAE.png",
        "medium": "https://api-assets.clashofclans.com/badges/200/xNJu5T7tzofI4dqzjZ8LdRMQ6sDDeNlpiFS2TnjPxAE.png"
      },
      "clanLevel": 7,
      "clanPoints": 28064,
      "clanVersusPoints": 26268,
      "requiredTrophies": 1500,
      "warFrequency": "always",
      "warWinStreak": 2,
      "warWins": 92,
      "isWarLogPublic": false,
      "members": 50,
      "memberList": [
        {
          "tag": "#G0JV8JQ8",
          "name": "seagull-白菜",
          "role": "coLeader",
          "expLevel": 192,
          "league": {
            "id": 29000021,
            "name": "Titan League I",
            "iconUrls": {
              "small": "https://api-assets.clashofclans.com/leagues/72/qVCZmeYH0lS7Gaa6YoB7LrNly7bfw7fV_d4Vp2CU-gk.png",
              "tiny": "https://api-assets.clashofclans.com/leagues/36/qVCZmeYH0lS7Gaa6YoB7LrNly7bfw7fV_d4Vp2CU-gk.png",
              "medium": "https://api-assets.clashofclans.com/leagues/288/qVCZmeYH0lS7Gaa6YoB7LrNly7bfw7fV_d4Vp2CU-gk.png"
            }
          },
          "trophies": 4916,
          "versusTrophies": 3970,
          "clanRank": 1,
          "previousClanRank": 1,
          "donations": 200,
          "donationsReceived": 251
        },
        {
          "tag": "#UYPVLG0U",
          "name": "锦瑟华年",
          "role": "coLeader",
          "expLevel": 177,
          "league": {
            "id": 29000021,
            "name": "Titan League I",
            "iconUrls": {
              "small": "https://api-assets.clashofclans.com/leagues/72/qVCZmeYH0lS7Gaa6YoB7LrNly7bfw7fV_d4Vp2CU-gk.png",
              "tiny": "https://api-assets.clashofclans.com/leagues/36/qVCZmeYH0lS7Gaa6YoB7LrNly7bfw7fV_d4Vp2CU-gk.png",
              "medium": "https://api-assets.clashofclans.com/leagues/288/qVCZmeYH0lS7Gaa6YoB7LrNly7bfw7fV_d4Vp2CU-gk.png"
            }
          },
          "trophies": 4751,
          "versusTrophies": 3128,
          "clanRank": 2,
          "previousClanRank": 2,
          "donations": 245,
          "donationsReceived": 249
        },
    
    ... snippped ...
    
      ]
    }}
    Forum cup organiser. The forum cup discord server is: https://discord.gg/KEUxV2e

  3. #3
    could you tell me where is wrong?

    Code:
    <!DOCTYPE html><html>
    <head>
      <meta charset="UTF-8">
    <?php
    $clantag = "#Y988UYVV";
    
    
    $token = "eyJ0eX....sK6A";
    
    
    $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($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);
    
    
    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>

  4. #4
    OnyxDS's Avatar
    Join Date
    Sep 2014
    Location
    Brexit Island
    Posts
    5,683
    The only thing I can see just reading the code is that both of these:
    Code:
        <tr>
          <td>Wars drawn</td><td><?php echo $data["warTies"]; ?></td>
        </tr>
        <tr>
          <td>Wars lost</td><td><?php echo $data["warLosses"]; ?></td>
        </tr>
    are invalid for any clan with a private war log. Those values aren't reported if the log is private.
    Last edited by OnyxDS; June 2nd, 2018 at 11:52 AM.
    Forum cup organiser. The forum cup discord server is: https://discord.gg/KEUxV2e

  5. #5
    Trainee
    Join Date
    Oct 2017
    Location
    Singapore
    Posts
    17
    The HTTP 500 Internal Server Error server error response code indicates that the server encountered an unexpected condition that prevented it from fulfilling the request.

    Add these few lines at the top of your code (within PHP tags) to see where the error is:

    PHP Code:
        ini_set('display_errors'1);
        
    ini_set('display_startup_errors'1);
        
    error_reporting(E_ALL); 

  6. #6
    #YPVJLPPR IS our clan, good to see u using it as an example in your post

  7. #7
    Forum Master Saleh47's Avatar
    Join Date
    Sep 2014
    Location
    Lebanon
    Posts
    12,283
    Quote Originally Posted by 943680363 View Post
    could you tell me where is wrong?

    Code:
    <!DOCTYPE html><html>
    <head>
      <meta charset="UTF-8">
    <?php
    $clantag = "#Y988UYVV";
    
    
    $token = "eyJ0eX....sK6A";
    
    
    $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($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);
    
    
    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>
    Check the red colored code. You are using double quotes for both src & array values. This is the cause of the error & any similar occasions. For future use what Polared suggested for debugging php scripts:
    Quote Originally Posted by Polared View Post
    The HTTP 500 Internal Server Error server error response code indicates that the server encountered an unexpected condition that prevented it from fulfilling the request.

    Add these few lines at the top of your code (within PHP tags) to see where the error is:

    PHP Code:
        ini_set('display_errors'1);
        
    ini_set('display_startup_errors'1);
        
    error_reporting(E_ALL); 
    Last edited by Saleh47; June 5th, 2018 at 12:18 PM.

    Thanks for ClashOfHolmes for his great work!

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
  •