0

Hello Everyone,

i am wanting to build a leaderboard for my site for the members gamerscore on Xbox LIVE. I know how to fech from a MySQL database, etc but this is the hard bit.

So the users table in MySQL contains their gamertag and i want to pull that out for each user and then get there gamerscore from a xml external below i will show you how to do it for one user which i use on their profile pages but i want a top 100 and the only prblem is that i have over 5000 members.

So here it is:

$gamertag = $fetch['gamertag'];
$xmlLocation = "http://xboxapi.duncanmackenzie.net/gamertag.ashx?GamerTag=".$gamertag;
$Gamerinfo = simplexml_load_file($xmlLocation);
	  
echo "Gamerscore: ".$Gamerinfo->GamerScore;

Now i think this would maybe go into a loop of some sort? But thanks and please help if you can.

Daniel

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by BlueCharge
0

Using a loop on 5000 members would take too much time simply because of the delay between the request and response of your xml request to the API.

I think that the best thing you can do, is requesting everyone's gamerscore once, putting it in the table, and then using that data to create your leaderboards. Although these scores are potentially "old", you can sort and display the data almost instantly.

In order to keep the scores updates, make sure you schedule a script to automatically refresh everyone's score once a day/week/...

Also, you could use this old data to fetch the top 150 (or something like that, at least more than the number you want to show) and refresh the score of the users in this list more often.

0

Thank you for your reply this was very helpful to me.

Regards,

Daniel

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.