Archive for Gaming

Using PHP and JSON with the Steam Web API

Since I’ve been struggling quite some time with this, I thought I would post this and hopefully speed a frustrated searcher along to their next coding conundrum.

Given the following:

1. A web server that supports PHP, and the dangerous knowledge to use the same.

2. The Steam Web API, and a current and valid API key to query it.

3. A valid Steam Community ID (mine is 76561197979917193 and is used below).

What PHP code can you use to get the Steam Web API to respond with valid JSON and display that on a web page? Note that the example below is sanitized to mask my actual API key. Use the link above and get your own!

Which results in: