Web Basic XBOX information grabber[php source code]

Discussion in 'Source Code & Tutorial Database' started by Revvv, Jun 20, 2013 with 28 replies and 4,489 views.

  1. Revvv

    Revvv Getting There

    Messages:
    2,013
    Ratings:
    265
    Just whipped up this code:
    PHP:
    <?PHP
     
    function getGamertagSource($gamertag)
    {
    $dom = new DOMDocument("1.0""utf-8");
    $dom->loadHTMLFile("http://gamercard.xbox.com/en-US/".str_replace(" ""%20"$gamertag).".card");
    $xpath = new DomXpath($dom);
    return array(
    'Gamertag' => $dom->getElementById('Gamertag')->textContent,'gamerscore' => $dom->getElementById('Gamerscore')->textContent'motto' => $dom->getElementById('Motto')->textContent'bio' => $dom->getElementById('Bio')->textContent'Reputation' => $xpath->query("//*[contains(concat(' ', normalize-space([USER=460461]class[/USER]), ' '), ' Star Full ')]")->length."*");
    }
     
     
    $gamertag getGamertagSource("major nelson");
     
    foreach(
    $gamertag as $item => $value){
    echo 
    $item.": ".$value."<br>";
    }
     
     
     
    ?>
    You can expand upon what I have given you. At the moment that will print out:
    Gamertag
    Gamerscore
    Motto
    Bio
    Reputation


    Enjoy.
     
  2. Z61

    Z61 Some times our saints are sinners Retired

    Messages:
    5,514
    Ratings:
    3,057
    It seems like you've hardcoded the user's id. Bad idea.
     
  3. OP
    Revvv

    Revvv Getting There

    Messages:
    2,013
    Ratings:
    265
    Huh?
     
  4. Fire30

    Fire30 Seasoned Member

    Messages:
    7,285
    Ratings:
    2,220
    I think there is supposed to be an '@' there and it automatically gets changed into [.USER=5387]UserName[./USER]
     
    • Like Like x 1
  5. OP
    Revvv

    Revvv Getting There

    Messages:
    2,013
    Ratings:
    265
    This :smile:
     
  6. TheChillerCraft

    TheChillerCraft Enthusiast

    Messages:
    534
    Ratings:
    54
    I wish xbox had an API for getting the last played games and if the user is online... The only way to do this is to either use someone elses API (https://www.xboxleaders.com/api/2.0/profile.json?gamertag=TheChillerCraft) or make your own, and to make your own you would have to deal with signing in all the time and keeping a cookie for the credentials and then parse the data from the xbox website...
     
  7. Z61

    Z61 Some times our saints are sinners Retired

    Messages:
    5,514
    Ratings:
    3,057
    When my site is back online, I can give you access to my api.
     
  8. TheChillerCraft

    TheChillerCraft Enthusiast

    Messages:
    534
    Ratings:
    54
    Does it do basically what I just sayed???!
     
  9. Z61

    Z61 Some times our saints are sinners Retired

    Messages:
    5,514
    Ratings:
    3,057
    it prints out json with user details. It counts the last 5 games. I haven't attempted to see if the user is online yet, but I can probably add it.
     
  10. OP
    Revvv

    Revvv Getting There

    Messages:
    2,013
    Ratings:
    265
    that would be easy? you dont need to sign in? I could add that to this?

    PHP:
            $dom = new DOMDocument("1.0""utf-8");
            
    $dom->loadHTMLFile("http://gamercard.xbox.com/en-US/".str_replace(" ""%20"$gamertag).".card");
            
    $xpath = new DomXpath($dom);
            
    $domm = new DOMDocument("1.0""utf-8");
            
    $domm->loadHTMLFile("https://live.xbox.com/en-US/Profile?Gamertag=".str_replace(" ""%20"$gamertag));
            
    $path = new DomXpath($domm);
            
    $pres $path->query("//*[contains([USER=460461]class[/USER], 'presence')]");
            foreach (
    $pres as $p){
                echo 
    "status: ".$p->nodeValuePHP_EOL."<br>";
            }
            return array(
    'Gamertag' => $dom->getElementById('Gamertag')->textContent,'gamerscore' => $dom->getElementById('Gamerscore')->textContent'motto' => $dom->getElementById('Motto')->textContent'bio' => $dom->getElementById('Bio')->textContent'Reputation' => $xpath->query("//*[contains(concat(' ', normalize-space([USER=460461]class[/USER]), ' '), ' Star Full ')]")->length."*");
        }
        
    $gamertag getGamertagSource($_GET['gt']);
        foreach(
    $gamertag as $item => $value){
            
    Easy as abc..I'll let you do recent games but all you got to do is scrape the information from:
    gamercard.xbox.com/en-US/{GAMERTAG}.card for the recent 5 games..and you have all the gamerscore, game completion percentage and so on and game picture.

    The above code will output this stuff:
    [​IMG]
    (major nelson doesnt have a motto or bio otherwise that would be there :tongue: )


    NOTE: in the code the [.USER=460461]class[/USER] is supposed to be @ class (minus the space, god damit user tagging!)
     
    • Like Like x 1
    Last edited: Jun 23, 2013
  11. TheChillerCraft

    TheChillerCraft Enthusiast

    Messages:
    534
    Ratings:
    54
    The gamercard.xbox.com does not give you your recently played games and does not tell you if the person is online or not, I tried everything, the only way is to log in to xbox.com and scrape the persons details from there.
     
  12. Z61

    Z61 Some times our saints are sinners Retired

    Messages:
    5,514
    Ratings:
    3,057
    gamercard lists the 5 most recently played games.
    http://gamercard.xbox.com/en-US/major nelson.card
     
  13. TheChillerCraft

    TheChillerCraft Enthusiast

    Messages:
    534
    Ratings:
    54
  14. Z61

    Z61 Some times our saints are sinners Retired

    Messages:
    5,514
    Ratings:
    3,057
    Well then, you're going to need to make a random account you aren't afraid to lose.
     
  15. TheChillerCraft

    TheChillerCraft Enthusiast

    Messages:
    534
    Ratings:
    54
    All you've got to do is make a script that logs a user in (can be any account, mainly your, because this is all server side and the users will not see the credentials) and save a cookie and visit the xbox site and scrape the data. [Click here to view the link] NVM that thought that was an actual api...

    Here is the good API: [Click here to view the link], except the auth system does not work :frown:...
     
    Last edited: Jun 24, 2013
  16. OP
    Revvv

    Revvv Getting There

    Messages:
    2,013
    Ratings:
    265
    This tells you if the user is online/offline? :S[DOUBLEPOST=1372091701][/DOUBLEPOST]
    Also gives you some details information on each:
    <a href="http://live.xbox.com/en-US/Activity/Details?titleId=1480659432&amp;compareTo=Major Nelson"> <img src="http://tiles.xbox.com/tiles/v9/YO/0mdsb2JhbA9ECgUAGwEeXwpbL2ljb24vMC84MDAwIAAAAAAAAP0h1qA=.jpg" alt="State of Decay" title="State of Decay"> <span class="Title">State of Decay</span> <span class="LastPlayed">6/6/2013</span> <span class="EarnedGamerscore">45</span> <span class="AvailableGamerscore">400</span> <span class="EarnedAchievements">5</span> <span class="AvailableAchievements">30</span> <span class="PercentageComplete">16%</span> </a>
     
  17. TheChillerCraft

    TheChillerCraft Enthusiast

    Messages:
    534
    Ratings:
    54
    Well I also need the users friends, which you have to be logged in to view...
     
  18. OP
    Revvv

    Revvv Getting There

    Messages:
    2,013
    Ratings:
    265
    Yeah!
     
  19. OP
    Revvv

    Revvv Getting There

    Messages:
    2,013
    Ratings:
    265
    I might make an xbox api as my first ever API as its pretty simple :tongue:
     
  20. TheChillerCraft

    TheChillerCraft Enthusiast

    Messages:
    534
    Ratings:
    54
    I am also going to try but we are going to have to do some research on how xbox logs in and how there cookies work...
     

Share This Page