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,500 views.

  1. OP
    Revvv

    Revvv Getting There

    Messages:
    2,013
    Ratings:
    265
    should be easy enough..im very experienced with http/s requests :smile:
     
  2. TheChillerCraft

    TheChillerCraft Enthusiast

    Messages:
    534
    Ratings:
    54
    Ya I am as well, but xbox uses javascript... So you can't just post the form and reload the page... It authenticates through javascript.
     
  3. OP
    Revvv

    Revvv Getting There

    Messages:
    2,013
    Ratings:
    265
    I actually did see a post url with all the login info..but i think i was lucky as it seems to almost delete that http request from the log of them since i first saw it :tongue:
     
  4. OP
    Revvv

    Revvv Getting There

    Messages:
    2,013
    Ratings:
    265
    Currently grabbing all this information atm..think im just waiting on getting friends list and im done :smile:
    PHP:
    [COLOR=#000000]stdClass Object
    (
        [
    accountData] => stdClass Object
            
    (
                [
    gamertag] => Major Nelson
                
    [gamerscore] => 63937
                
    [motto] => 
                [
    bio] => 
                [
    currentStatus] => Last seen 58 minutes ago playing Xbox.com
            
    )

        [
    accountImages] => stdClass Object
            
    (
                [
    gamerpic] => http://avatar.xboxlive.com/avatar/Major%20Nelson/avatarpic-l.png
                
    [fullAvatar] => https://avatar-ssl.xboxlive.com/avatar/major%20nelson/avatar-body.png
            
    )

        [
    recentGames] => Array
            (
                [
    0] => Array
                    (
                        [
    0] => stdClass Object
                            
    (
                                [
    game_title] => Battlefield 3
                                
    [last_played] => 6/25/2013
                                
    [earned_gamerscore] => 680
                                
    [available_gamerscore] => 1600
                                
    [earn_achievments] => 28
                                
    [available_achievments] => 63
                                
    [game_complete_percentage] => 44%
                            )

                        [
    1] => stdClass Object
                            
    (
                                [
    game_title] => Halo 4
                                
    [last_played] => 6/24/2013
                                
    [earned_gamerscore] => 825
                                
    [available_gamerscore] => 1750
                                
    [earn_achievments] => 43
                                
    [available_achievments] => 76
                                
    [game_complete_percentage] => 56%
                            )

                        [
    2] => stdClass Object
                            
    (
                                [
    game_title] => Borderlands 2
                                
    [last_played] => 6/23/2013
                                
    [earned_gamerscore] => 770
                                
    [available_gamerscore] => 1625
                                
    [earn_achievments] => 36
                                
    [available_achievments] => 69
                                
    [game_complete_percentage] => 52%
                            )

                        [
    3] => stdClass Object
                            
    (
                                [
    game_title] => State of Decay
                                
    [last_played] => 6/6/2013
                                
    [earned_gamerscore] => 45
                                
    [available_gamerscore] => 400
                                
    [earn_achievments] => 5
                                
    [available_achievments] => 30
                                
    [game_complete_percentage] => 16%
                            )

                        [
    4] => stdClass Object
                            
    (
                                [
    game_title] => Far Cry 3 Blood Dragon
                                
    [last_played] => 5/28/2013
                                
    [earned_gamerscore] => 80
                                
    [available_gamerscore] => 400
                                
    [earn_achievments] => 4
                                
    [available_achievments] => 19
                                
    [game_complete_percentage] => 21%
                            )

                    )

            )
     [/
    COLOR]
    [
    COLOR=#000000])[/COLOR]
     
  5. OP
    Revvv

    Revvv Getting There

    Messages:
    2,013
    Ratings:
    265
    I'm bored now. Enjoy:

    backbone.php
    PHP:
    <?PHP
     
    class XboxApi {
     
            public function 
    customURLEncode($string)
            {
                return 
    str_replace(" ""%20"$string);
            }
     
          
            public function 
    profile_status($gamertag)
            {
                
    $dom = new DOMDocument("1.0""utf-8");
                
    $dom->loadHTMLFile("https://live.xbox.com/en-US/Profile?Gamertag=".str_replace(" ""%20"$gamertag));
                
    $dom = new DomXpath($dom);
             
                foreach(
    $dom->query("//*[contains([USER=460461]class[/USER], 'presence')]") as $s)
                {
                    return 
    $s->nodeValue;
                }
             
             
             
            }
     
            
    //gets all profile information
            
    public function all_profile($gamertag)
            {
                    
    $gamertagData = new DOMDocument("1.0""utf-8");
                    
    $gamertagData->loadHTMLFile("http://gamercard.xbox.com/en-US/".str_replace(" ""%20"$gamertag).".card");
                 
                    return 
    json_encode(array(
                 
                    
    'accountData' => array(
                        
    'gamertag' => $gamertagData->getElementById('Gamertag')->textContent,
                        
    'gamerscore' => $gamertagData->getElementById('Gamerscore')->textContent,
                        
    'motto' => $gamertagData->getElementById('Motto')->textContent,
                        
    'bio' => $gamertagData->getElementById('Bio')->textContent,
                        
    'currentStatus' => $this->profile_status($gamertag)
                        ),
                 
                    
    'accountImages' => array(
                            
    'gamerpic' => $gamertagData->getElementById('Gamerpic')->getAttribute('src'),
                            
    'fullAvatar' => "https://avatar-ssl.xboxlive.com/avatar/".$this->customURLEncode($gamertag)."/avatar-body.png"
                        
    ),
                 
                    
    'recentGames' => array(
                            
    $this->profile_recent_games($gamertag)
                        )
                        ));
            }
         
            public function 
    profile_recent_games($gamertag)
            {
                
    $gamertagData = new DOMDocument("1.0""utf-8");
                
    $gamertagData->loadHTMLFile("http://gamercard.xbox.com/en-US/".str_replace(" ""%20"$gamertag).".card");
                
    $games explode("\n"$gamertagData->getElementById('PlayedGames')->textContent);
                
    //print_r($games);
                
    $recentGames = array();
                foreach(
    $games as $game){
                    if(
    strlen(trim($game)) > 0){
                        
    array_push($recentGamestrim($game));
                    }
                }
                
    $recentGames array_chunk($recentGames7);
                foreach(
    $recentGames as $key => $value){
                    
    $recentGames[$key]['game_title'] = $recentGames[$key][0];
                    unset(
    $recentGames[$key][0]);
                    
    $recentGames[$key]['last_played'] = $recentGames[$key][1];
                    unset(
    $recentGames[$key][1]);
                    
    $recentGames[$key]['earned_gamerscore'] = $recentGames[$key][2];
                    unset(
    $recentGames[$key][2]);
                    
    $recentGames[$key]['available_gamerscore'] = $recentGames[$key][3];
                    unset(
    $recentGames[$key][3]);
                    
    $recentGames[$key]['earn_achievments'] = $recentGames[$key][4];
                    unset(
    $recentGames[$key][4]);
                    
    $recentGames[$key]['available_achievments'] = $recentGames[$key][5];
                    unset(
    $recentGames[$key][5]);
                    
    $recentGames[$key]['game_complete_percentage'] = $recentGames[$key][6];
                    unset(
    $recentGames[$key][6]);
                }
                return 
    $recentGames;
            }
     
     
    }

    main.php
    Code:
    <?PHP
    error_reporting(1);
    include("backbone.php");
     
        $xbox = new XboxApi();
        echo "<pre>";
        print_r(json_decode($xbox->all_profile("major nelson")));
     
  6. TheChillerCraft

    TheChillerCraft Enthusiast

    Messages:
    534
    Ratings:
    54
    I know how to do all that basic stuff, but things like their friends list is quite tricky...
     
  7. Lochie

    Lochie Enthusiast

    Messages:
    37
    Ratings:
    59
    Having done all of this I can tell you that it is much more complicated than it seems. I'm currently working on accessing official authentication through Microsoft OAuth - which would really provide the best experience for users.
     
    • Like Like x 1
  8. realjblaze

    realjblaze Newbie

    Messages:
    1
    Ratings:
    0
  9. Markojokanovic

    Markojokanovic Newbie

    Messages:
    1
    Ratings:
    0
    Frend plz help me ? Need free gold for xbox360 one month? Plz help me ??? Thanks from Serbia
    [email protected].
    Tnx brooo
     

Share This Page