Phil Hassey - game dev blog
Phil Hassey as Wolverine
"What kind of
arrogant jerk
has a website like this?"

Dynamite: Day 21 – Web API

So .. I spent all day today getting some of my Web API up and running! Here’s some of what went into this:

– I considered using libcurl or some other pre-made solution for making web requests. However they were all too heavy-weight or did not support Windows.

– I ended up taking the code I had written for Galcon’s web API and cleaned it up a bit. I also wrapped it with a nice C++ wrapper so it would integrate more cleanly with my new codebase. I can now make web requests like this:

WebRequest r;
r.host = “www.galcon.com”;
r.request = “/somegame/api.php?action=dostuff”
r.post = string(“data=”)+r.urlencode(&game.data,sizeof(game.data));
r.exec();
while (!r.poll()) { … wait … }
results = r.get_response()

This is nice and simple and asynchronous. I am able to make these requests, and call poll() once a frame, and then once it’s done polling I can handle the results.

Since I had taken the time to do all this, I figured I’d spice things up by integrating some kind of analytics package with it so I could see where the rough areas are in my game. Unfortunately, no analytics package I found has a “super simple officially supported web-API” .. I may however give playtomic a whirl, it seems to be pretty simple web API calls from looking at the API code, but it’s really for flash .. in the meantime I’ve got a database setup that captures my tracking calls. But I’ll be looking at other options.

To wrap things up today, my biggest goal is to be able to share levels between players. Since I’ve got my web calls working, this should go pretty easily. It’s 3:30 now, so let’s see how long it takes to get this up and running. And, 3 hours later, I’ve got sharing working! Wooo! It’s still not quite as elegant as it needs to be, but it does work to some extent.

-Phil

Comments are closed.