{"id":722,"date":"2010-10-25T19:30:19","date_gmt":"2010-10-26T01:30:19","guid":{"rendered":"http:\/\/www.philhassey.com\/blog\/?p=722"},"modified":"2010-10-25T19:30:19","modified_gmt":"2010-10-26T01:30:19","slug":"dynamite-day-21-web-api","status":"publish","type":"post","link":"https:\/\/www.philhassey.com\/blog\/2010\/10\/25\/dynamite-day-21-web-api\/","title":{"rendered":"Dynamite: Day 21 &#8211; Web API"},"content":{"rendered":"<p>So .. I spent all day today getting some of my Web API up and running!  Here&#8217;s some of what went into this:<\/p>\n<p>&#8211; 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.<\/p>\n<p>&#8211; I ended up taking the code I had written for Galcon&#8217;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:<\/p>\n<p>WebRequest r;<br \/>\nr.host = &#8220;www.galcon.com&#8221;;<br \/>\nr.request = &#8220;\/somegame\/api.php?action=dostuff&#8221;<br \/>\nr.post = string(&#8220;data=&#8221;)+r.urlencode(&#038;game.data,sizeof(game.data));<br \/>\nr.exec();<br \/>\nwhile (!r.poll()) { &#8230; wait &#8230; }<br \/>\nresults = r.get_response()<\/p>\n<p>This is nice and simple and asynchronous.  I am able to make these requests, and call poll() once a frame, and then once it&#8217;s done polling I can handle the results.<\/p>\n<p>Since I had taken the time to do all this, I figured I&#8217;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 &#8220;super simple officially supported web-API&#8221; .. I may however give <a href=\"http:\/\/playtomic.com\/\">playtomic<\/a> a whirl, it seems to be pretty simple web API calls from looking at the API code, but it&#8217;s really for flash .. in the meantime I&#8217;ve got a database setup that captures my tracking calls.  But I&#8217;ll be looking at other options.<\/p>\n<p>To wrap things up today, my biggest goal is to be able to share levels between players.  Since I&#8217;ve got my web calls working, this should go pretty easily.  It&#8217;s 3:30 now, so let&#8217;s see how long it takes to get this up and running.  And, 3 hours later, I&#8217;ve got sharing working!  Wooo!  It&#8217;s still not quite as elegant as it needs to be, but it does work to some extent.<\/p>\n<p>-Phil<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So .. I spent all day today getting some of my Web API up and running! Here&#8217;s some of what went into this: &#8211; 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. &#8211; I ended up taking the code [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[116],"tags":[],"class_list":["post-722","post","type-post","status-publish","format-standard","hentry","category-dynamite"],"_links":{"self":[{"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/posts\/722","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/comments?post=722"}],"version-history":[{"count":1,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/posts\/722\/revisions"}],"predecessor-version":[{"id":723,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/posts\/722\/revisions\/723"}],"wp:attachment":[{"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/media?parent=722"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/categories?post=722"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/tags?post=722"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}