Xbox Achievements Plugin

As some of you may know, i built a site http://xbonx.com which tracks gamertags. It creates game logs for every game you play and accounts achievements you earn.

Anyways, onto what i want to talk about.

I always wanted to integrate some xbox live stuff into my blog. A friend of mine @Cadab had already created a nice little xbox widget for his blog.

As you can see, he has a nice little widget which sits on his blogs sidebar and grabs the last 5 achievements which then link to a nice page which displays all his games from a database.

So, i wanted to create one for myself. I had all the data i needed already. xBonx was tracking all my gamerscore and achievements already so i could just select from the correct databases and supply my gamertag and boom, id have all the date.

In the end, i decided against this method.

I started out by searching the jQuery library for a nice way to display my games. I didnt want to just to a drop down, i wanted something different! I found a nice jQuery carousel on google and decided to go with this.

Getting my date from xbox.com is probably the bit that most people would struggle with. Fortunately, there is a brilliant un-official API created by @djekl which will get everything you need from your xbox profile. More information on the API here: http://xboxapi.com.

The API displays all the results in json. I wrote a little php script which reads the json and then displays it however you want. I spent some time messing around with the layout, adding my avatar and the left and right buttons.

As well as the API offering the games played and achievements earned, it also displays some statistics. It only offers gamerscore, total games played and total percentage.

Using this information, i managed to create some better statistics.

To work out my current gamerscore, i used the total gamerscore available from every game, added it all together and got that total!

I used the same method as above to work out total achievements. Adding together the total amount available of every game i played.

For total games, i did not use the one displayed on the API. The API displays all the games and apps and anything else you have played using your xbox gamertag. EG: Sky, Lovefilm, Internet Explorer. So, i had all the code available already, so wrote a simple if command to get the count of true games excluding apps.

if($gamePossibleScore != '0')
{
$myGames++;
}

So, if a games total gamerscore is equal to 0, then this means its not a game and i will exclude it from my total game count.

Then to work out how many of the above games i had completed i did this.

So basically, if the total possible gamerscore of a game is equal to the gamerscore i have earned in the game, this will be classed as a completed game. I increment $completedGame by 1.

So that is basically where i got to. I need to wrap it all up nicely and then figure out how you make plugins install in wordpress.

You can view the ‘My Achievements’ page by clicking the new tab in the header or simply by clicking this link: http://bonxy.info/xbox.php.

Here are some screen shots.

Leave a Reply

Your email address will not be published. Required fields are marked *