What's new

Web Basic XBOX information grabber[php source code]

Revvv

Revvv

Getting There
Experienced Veteran Grizzled Veteran Seasoned Veteran
Messages
1,924
Reaction score
290
Points
220
Sin$
0
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.
 
Z61

Z61

Some times our saints are sinners
Retired
Programmer Forum Addict Odysseus' Summit
Messages
5,468
Reaction score
3,429
Points
1,042
Sin$
0
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.

It seems like you've hardcoded the user's id. Bad idea.
 
TheChillerCraft

TheChillerCraft

Enthusiast
Messages
540
Reaction score
74
Points
95
Sin$
7
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...
 
Z61

Z61

Some times our saints are sinners
Retired
Programmer Forum Addict Odysseus' Summit
Messages
5,468
Reaction score
3,429
Points
1,042
Sin$
0
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...

When my site is back online, I can give you access to my api.
 
Z61

Z61

Some times our saints are sinners
Retired
Programmer Forum Addict Odysseus' Summit
Messages
5,468
Reaction score
3,429
Points
1,042
Sin$
0
Does it do basically what I just sayed???!

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.
 
Revvv

Revvv

Getting There
Experienced Veteran Grizzled Veteran Seasoned Veteran
Messages
1,924
Reaction score
290
Points
220
Sin$
0
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...

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->nodeValue, PHP_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:
hwwI1LP.png

(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!)
 
Last edited:
TheChillerCraft

TheChillerCraft

Enthusiast
Messages
540
Reaction score
74
Points
95
Sin$
7
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->nodeValue, PHP_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:
hwwI1LP.png

(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!)

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.
 
Z61

Z61

Some times our saints are sinners
Retired
Programmer Forum Addict Odysseus' Summit
Messages
5,468
Reaction score
3,429
Points
1,042
Sin$
0
Z61

Z61

Some times our saints are sinners
Retired
Programmer Forum Addict Odysseus' Summit
Messages
5,468
Reaction score
3,429
Points
1,042
Sin$
0
But I need to tell when someones online and I need their friends list. You have to be logged in to view those...

Well then, you're going to need to make a random account you aren't afraid to lose.
 
TheChillerCraft

TheChillerCraft

Enthusiast
Messages
540
Reaction score
74
Points
95
Sin$
7
Well then, you're going to need to make a random account you aren't afraid to lose.

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 this link] NVM that thought that was an actual api...

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

Revvv

Getting There
Experienced Veteran Grizzled Veteran Seasoned Veteran
Messages
1,924
Reaction score
290
Points
220
Sin$
0
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.

This tells you if the user is online/offline? :S 
gamercard lists the 5 most recently played games.
http://gamercard.xbox.com/en-US/major nelson.card

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>
 
TheChillerCraft

TheChillerCraft

Enthusiast
Messages
540
Reaction score
74
Points
95
Sin$
7
This tells you if the user is online/offline? :S 


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>

Well I also need the users friends, which you have to be logged in to view...
 
Revvv

Revvv

Getting There
Experienced Veteran Grizzled Veteran Seasoned Veteran
Messages
1,924
Reaction score
290
Points
220
Sin$
0
I might make an xbox api as my first ever API as its pretty simple :tongue:
 
TheChillerCraft

TheChillerCraft

Enthusiast
Messages
540
Reaction score
74
Points
95
Sin$
7
I might make an xbox api as my first ever API as its pretty simple :tongue:

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...
 
Top Bottom
Login
Register