www.webdeveloper.com
Results 1 to 9 of 9

Thread: XML Script for a WEBPAGE NEEDED for a STEAM API Module on Clan Website - PLEASE HELP!

Hybrid View

  1. #1
    Join Date
    Apr 2013
    Posts
    6

    Wink XML Script for a WEBPAGE NEEDED for a STEAM API Module on Clan Website - PLEASE HELP!

    Hello all,

    This is my first post here and I am after a script for a steam API .xml url tp go onto a custom HTML module for my Game Clan Website, ok I will give you some background information here.

    Ok I have a STEAM API KEY and I have a steam id etc, now the steam XML feed is the following:

    I have tried so many scripts out there, done so much reading but I am just not a coder I cannot get this to work, can someone please give me the script I would need.

    Ok here is an example of a steam feed that I want to use:

    http://api.steampowered.com/ISteamUs...380&format=xml

    ok that will live on this page:

    http://www.mdexter.com/aoe2hdozclan.com/steam.htm

    Now I have to link it to my website module which is on this page at the very bottom

    www.aoe2hdozclan.com in the module at the very bottom with the name:

    STEAM AoE2 HD Global Achievements (testing)

    Ok so the HTML module needs to get the xml page as above ((PLEASE NOTE MY WEB HOST DOES NOT ALLOW XML ETC PAGES SO I HAVE TO DO THE XML PAGE OFFSITE WHICH IS OK))

    So the module you see at the bottom of the page at www.aoe2hdozclan.com have a HTML module which has the following html code:

    OK NOW THE ISSUE IS:

    I cannot load the xml feed into the page above at:

    http://www.mdexter.com/aoe2hdozclan.com/steam.htm

    it does not load into the above page, the url makes the page have the white background etc, I cannot get the contents of the feed to load into the above webpage....I have tried ending the page in .php etc.

    Can someone please help me get the script for the above page to load the xml feed into the page at:

    http://www.mdexter.com/aoe2hdozclan.com/steam.htm the "steam..htm" page with the background colour and fonts etc so it can load properly into the webpage module at www.aoe2hdozclan.com

    I have tried Steam forums, no replies, I have tried another two forums on the web and no replies, I am not a coder,, I am more of a designer of graphics etc and just cannot get my head around the xml feed...but I know the members of the clan we have will be very pleased as this information is really important.

    Please can someone help us out with the script for the webpage to make this load with the font type and colour etc, thanks so very much in advance..

    Cheers

  2. #2
    Join Date
    Apr 2013
    Posts
    6
    please, please can someone help me here

  3. #3
    Join Date
    Jul 2012
    Posts
    57
    Wait a second.. since when did xml become a scripting language? lulz.
    XML contains easy data structures for simple parsing. It's not going to do anything more then a text file would. YOU have to design a script to parse the data yourself, can easily be done in perl, php, or even javascript

    Pulled from the W3 themselves: XML is designed to transport and store data.
    I'll be nice and get you started..

    Code:
    <script>
    if (window.XMLHttpRequest) {
     xmlhttp=new XMLHttpRequest(); //make request
    }
    else {
     xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); //in case there is a moron using IE
    }
    xmlhttp.open("GET","YOURSTEAMXMLFILE",false);
    xmlhttp.send();
    xmlDoc=xmlhttp.responseXML; 
    
    //write or assign an element a table to neatly place info
    document.write("<table border='99999999999999999999999999999999999999999999999'>");
    var x=xmlDoc.getElementsByTagName("achievement");
    for (i=0;i<x.length;i++)
      { 
      document.write("<tr><td>");
      document.write(x[i].getElementsByTagName("name")[0].childNodes[0].nodeValue);
      document.write("</td><td>");
      document.write(x[i].getElementsByTagName("percentage")[0].childNodes[0].nodeValue);
      document.write("</td></tr>");
      }
    document.write("</table>");
    </script>
    There you go, hopefully you get the concept!

  4. #4
    Join Date
    Apr 2013
    Posts
    6
    VERY SORRY FOR THIS BUT JUST AN UPDATE, OK THIS IS WHERE I AM AT NOW, TRYING TO DO THE FOLLOWING:

    Page is found here BTW:

    http://www.mdexter.com/aoe2hdozclan.com/rankings1.php

    1 . Remove errors, some name entries have errors and an error that comes up with the following:

    Warning: DOMDocument::load() [domdocument.load]: Document is empty in http://steamcommunit...085870722?xml=1, line: 1 in /home/mp/public_html/aoe2hdozclan.com/test.php on line 78

    The line in question is:
    PHP Code:

        
    isset($friendsOf) ? $friendsOf.'/' ''
        
    ).'?xml=1&start=' $start '&end=' $end,
        
    LIBXML_NOBLANKS || LIBXML_NOCDATA
    )) {

        
    $entries $feed->getElementsByTagName('entries');
        if (
    $entries->length>0) { 
    THE LINE IN QUESTION IS THIS: )) {

    which I have a temp fix using:

    // Turn off all error reporting
    error_reporting(0);

    2. Change where avatar is and move it to where rating is, and move rating and rank to the right, and REMOVE UGCID alltogether

    3. Add the avatarMedium from xml details below which adds an avatar image to the avatar column, details of parser found here:

    PHP Code:

    <profile>
    <
    steamID64>76561197963686471</steamID64>
    <
    steamID>-Dare Devil/x/</steamID>
    <
    onlineState>offline</onlineState>
    <
    stateMessage>Last Online2 hrs33 mins ago</stateMessage>
    <
    privacyState>public</privacyState>
    <
    visibilityState>3</visibilityState>
    &
    #8722;
    <avatarIcon>
    http://media.steampowered.com/steamcommunity/public/images/avatars/54/5407c772b001238b61a47762bb57494b0b940e96.jpg
    </avatarIcon>
    &
    #8722;
    <avatarMedium>
    http://media.steampowered.com/steamcommunity/public/images/avatars/54/5407c772b001238b61a47762bb57494b0b940e96_medium.jpg
    </avatarMedium>
    &
    #8722;
    <avatarFull>
    http://media.steampowered.com/steamcommunity/public/images/avatars/54/5407c772b001238b61a47762bb57494b0b940e96_full.jpg
    </avatarFull>
    <
    vacBanned>0</vacBanned>
    <
    tradeBanState>None</tradeBanState>
    <
    isLimitedAccount>0</isLimitedAccount>
    <
    customURL>jsmucha</customURL>
    <
    memberSince>January 12004</memberSince>
    <
    steamRating>10</steamRating>
    <
    hoursPlayed2Wk>69.7</hoursPlayed2Wk>
    <
    headline></headline>
    <
    location>DanburyConnecticutUnited States</location>
    <
    realname></realname>
    <
    summary>I like dragons. And zombies.</summary>
    &
    #8722;
    <mostPlayedGames>
    &
    #8722;
    <mostPlayedGame>
    <
    gameName>Age of Empires IIHD Edition</gameName>
    <
    gameLink>http://steamcommunity.com/app/221380</gameLink>
    &#8722;
    <gameIcon>
    http://media.steampowered.com/steamcommunity/public/images/apps/221380/109c74df17f9b67ea47d8f01e3d1ec25278b9f73.jpg
    </gameIcon>
    &
    #8722;
    <gameLogo>
    http://media.steampowered.com/steamcommunity/public/images/apps/221380/37e9da3f1174891fe38f8fb0206acda8b6bfc729.jpg
    </gameLogo>
    &
    #8722;
    <gameLogoSmall>
    http://media.steampowered.com/steamcommunity/public/images/apps/221380/37e9da3f1174891fe38f8fb0206acda8b6bfc729_thumb.jpg
    </gameLogoSmall>
    <
    hoursPlayed>58.1</hoursPlayed>
    <
    hoursOnRecord>110</hoursOnRecord>
    <
    statsName>AgeofEmpiresIIHDEdition</statsName
    The item to parse and create the avatar is: <avatarMedium>

    And that is it for now I have tried so many types of scripts etc but I am coming up short, ok the full script of the page is below:

    PHP Code:

    <?php
       
      
    // Turn off all error reporting
    error_reporting(0);
     
       
    header("Cache-Control: no-cache, must-revalidate");
    header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");

    /* 
        I limited it to ten because it takes so long to pull every user's
        profile! I suggest setting up some sort
    of caching or daily updates
        if deploying this live.
    */

    $start 1;
    $end 40;
    $friendsOf 133447;
     
    $game 'AgeofEmpiresIIHDEdition';

    $feed = new DOMDocument();
    if (
    $feed->load(
        
    'http://steamcommunity.com/stats/' $game '/leaderboards/'.(
            isset(
    $friendsOf) ? $friendsOf.'/' ''
        
    ).'?xml=1&start=' $start '&end=' $end,
        
    LIBXML_NOBLANKS || LIBXML_NOCDATA
    )) {

        
    $entries $feed->getElementsByTagName('entries');
        if (
    $entries->length>0) {
        
            
    $entries $entries->item(0)->getElementsByTagName('entry');
            if (
    $entries->length>0) {
            
                echo 
    '
                    <table id="leaderBoard">
                        <caption>Age of Empires II HD Leaderboard</caption>
                        <thead>
                            <tr>
                                <th scope="col">Name</th>
                                <th scope="col">Rating</th>
                                <th scope="col">Rank</th>
                                <th scope="col">UGCID</th>
    <th scope="col">Avatar</th>
                            </tr>


    <style>


    table, th
    body {
    font-family:Verdana, Arial, Helvetica;
    font-size: 110%;
    padding-left: 15px;
    margin: 0px;
    color: #825a15;
    font-weight:bold;
    }
    th, td
    {
    border:1px solid black;
    }
    td, th
    {
    background-color:ebcc9b;
    }
    th, td
    {
    padding-right: 15px;
    }
    th
    {
    padding-left: 15px;
    }



    </style>

                        </thead><tbody>'
    ;
                        
                        
                        
                
                foreach (
    $entries as $entry) {

                
                    
    $data $entry->firstChild;
                    
                    
    $user = new DOMDocument;
                    if (
    $user->load(
                        
    'http://steamcommunity.com/profiles/' $data->nodeValue '?xml=1',
                        
    LIBXML_NOBLANKS || LIBXML_NOCDATA
                
    )) {
                        
    $userName $user->getElementsByTagName('steamID')->item(0)->nodeValue;
                        
    // note ALL user data is available here 
                    
    } else $userName '<strong>ERROR</strong>';
                    
                    
                    echo 
    '
                            <tr>
                                <th scope="row">'
    $userName'</th>';
                                
                    while (
    $data $data->nextSibling) echo '
                                <td>'
    $data->nodeValue'</td>';
                                
                    echo 
    '
                            </tr>'
    ;
                            
                } 
    // foreach $entries
                
                
    echo '
                        </tbody>
                    </table>'
    ;
                    
    } else echo 
    '<p>no entries found in entry
    table</p>'
    ;
            
        } else echo 
    '<p>no entries table found</p>';
        
    } else echo 
    '<p>unable to load feed</p>';
    ?>

      <?php
     
    // Do some form processing here
     
    echo '<a href="rankings2.php" font="Arial" style="color: #7d4417">next</a>';

     
    ?>

  5. #5
    Join Date
    Jul 2012
    Posts
    57
    You're not even on the right track, why don't you try my example? You don't need to do this in php, your making it harder for yourself.

  6. #6
    Join Date
    Apr 2013
    Posts
    6
    Hello there,

    I did try your example, but the page appears blank:

    <script>
    if (window.XMLHttpRequest) {
    xmlhttp=new XMLHttpRequest(http://api.steampowered.com/ISteamUs...ormat=xml&t=); //make request
    }
    else {
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); //in case there is a moron using IE
    }
    xmlhttp.open("GET","YOURSTEAMXMLFILE",false);
    xmlhttp.send();
    xmlDoc=xmlhttp.responseXML;

    //write or assign an element a table to neatly place info
    document.write("<table border='99999999999999999999999999999999999999999999999'>");
    var x=xmlDoc.getElementsByTagName("achievement");
    for (i=0;i<x.length;i++)
    {
    document.write("<tr><td>");
    document.write(x[i].getElementsByTagName("name")[0].childNodes[0].nodeValue);
    document.write("</td><td>");
    document.write(x[i].getElementsByTagName("percentage")[0].childNodes[0].nodeValue);
    document.write("</td></tr>");
    }
    document.write("</table>");
    </script>

    Cheers mate and thank you for getting back to me

  7. #7
    Join Date
    Feb 2013
    Location
    USA
    Posts
    40
    Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic.

  8. #8
    Join Date
    Jul 2012
    Posts
    57
    Bull crap, you just want me to code it for you so you can get it done. You are not looking to learn anything, and if you are you are not on the right track, and you can start by google searching for ... javascript tutorials. If you want to just get it done, hire a web developer to do this for you. They have professional experience (hopefully) and will know how to make things efficient as you could potentially compromise systems and paste inefficient code if you don't know what you are doing. Same thing as "do not operate this machine unless you are trained."

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles