Background
Few days back, I gave myself this challenge: I want a list of the games I play to put on this webpage.
Easily done to write one up and put it here, but I had a couple of concerns. I don’t want to have to update it every time I start or stop playing a game, and I don’t want it to show games I stopped playing long time ago.
So I made myself a list with specifications:
- Automatically updated
- Current games only
- Sorted list, most active on top
- List includes game graphics or icons
- Cache remote data, out of good habit
Xfire
My first design choice was to create a PHP page using data from Xfire. With Xfire I have access to my list of games, and can sort out which ones I visited in the last 7 days. Did consider Steam, but couldn’t be too sure how it would work out with non-Steam games. Or would it even function at all if my profile was set to private?
A drawback with Xfire is how you get access to the gameplay feeds. Your webserver IP has to be enabled on your account, and you have to send you username and password in cleartext each time you access the feed. To make it slightly worse, a single Xfire account can only have one IP tied to it. For my own safety, I created a new Xfire account with the sole purpose of holding my webserver IP and access the restricted XML feeds. Xfire confirms that this is the recommended way of doing it, as they acknowledge the security risks involved in sending passwords of personal accounts unencrypted over the Internet.
Before I actually got any work done, I contacted Xfire support and requested access from my webserver IP with the new secondary Xfire account I created. By doing this first I could download my XML file and get an idea of what I’m up against.
The Xfire feed I plan to use is available at http://www.xfire.com/xml/xfireusername/user_gameplay/ once Xfire adds my webserver IP to an account. It appears important that the IP is added to the account I will be using for cleartext authentication, so the IP has to be tied to the second account I created just for this purpose. The username in the address is replaced with my main Xfire ID, while the secondary account with password is added behind the address as GET parameters. Accessing the feed without login info gives an error notice specifying the need to use the format <url>?u=<xfire login>&p=<xfire password> where the orange parts are replaced with real information.
To sum up some of the Xfire stuff: You don’t have to log in with the username you’re trying to get feeds from, but the one you use for login must be associated with the webserver IP and should not be used for anything else. At least nothing important you can’t afford to loose.
Coding
The next thing I did, was to prepare one of my previous PHP-classes for new use. It is a download class that copies remote data and stores a local cache for some time before it’s redownloaded. I was quite confident it would be handy as my gameplay doesn’t warrant updates every few seconds, and I already had a simple code for using a cache. Not perfect, but it gets the job done.
Now that I have a sample XML and a functional downloader, I’m prepared to proceed with the next step. Start planning how my program should work with the XML data. That also means I need to attack it from the other end and make some decisions on what I want to end up with.
Will share some code when I no longer make changes to it. Can’t say when, as work on this undertaking will be on and off.