As mentioned in a previous post, I’ve developed a WordPress plug-in to display a user’s Steam Stats as a widget. It’s available for download here. However, this does no good to anyone without a WordPress-based-site and I wanted to make the source freely available. As such, I’ve included it below. Valve provides Steam profiles as an XML feed which can be parsed and formatted according to a developer’s needs. To personalize the script, simply edit the URL following the “$profileURL” variable.
<?php /* Steam Community Widget */ //Variables. Edit Profile URL to match the link to your personal Steam Community Page. $ProfileURL = 'http://steamcommunity.com/profiles/76561197970479548/'; $xml = simplexml_load_file($ProfileURL . '?xml=1'); //Begin Widget Content echo '<p><strong>SteamID:</strong> '; echo $xml->steamID . '<br /><strong>Member since:</strong> '; echo $xml->memberSince . '<br /><strong>Steam Rating:</strong> '; echo $xml->steamRating . '<br /><strong>Playing time:</strong> '; echo $xml->hoursPlayed2Wk . " hrs past 2 weeks</p>"; for($i = 0; $i < 4; $i++){ if ($xml->mostPlayedGames->mostPlayedGame[$i]->gameLink != "") { echo '<p><a href="' . $xml->mostPlayedGames->mostPlayedGame[$i]->gameLink . '"><img src="' . $xml->mostPlayedGames->mostPlayedGame[$i]->gameIcon . '" /></a> ' . $xml->mostPlayedGames->mostPlayedGame[$i]->gameName . ' ' . $xml->mostPlayedGames->mostPlayedGame[$i]->hoursPlayed . ' hrs</p>'; } } echo '<p><a href="' . $ProfileURL . 'games">View all games</a></p><p align="center"><em>© ' . date(Y) . ' <a href="http://nicholaspier.com">nicholaspier.com</a></em></p>'; //End Widget Content ?>


Pingback: Steam XML Parser | nicholaspier.com | Drakz Free Online Service
My pleasure. I couldn’t find one that did what I wanted so I just made my own
! Hope you enjoy it, do what you want with the source code
Nice work, thanks! Been looking for a WordPress/Steam plugin and the code will come in handy for other projects!
Hi I was just wondering if you can call this plugin directly, as I am not really using sidebars on my site.
How do i go about calling it on it’s own?
cheers!
The plugin is designed as a widget. I could redesign it where you’d enter text like < -- steamstats --> in a page or post like other plugins. However I don’t really have a need to redesign it. If you’d like it modified and are willing to paypal me like $15-20, I’d make the changes and send you a custom copy of the plugin.
Hi,
I run a large online community and I wanted to know if this plugin could show group details instead of individual details?
Regards,
Sable
Cheers! I was just about to embark on a similar quest … thanks for releasing the code. I first saw a forum post of yours that said it was a WordPress plugin, and I was dreading going through the source and de-tangling it from WP.
Right now I’m rewriting my WP blog from scratch in CodeIgniter so this is a huge help.
Thanks!