Hello folks.
I am currently in process of putting around a Web version of my last app for Dota2 Stats on iOS. BTW, the developing the same using Adobe Flash Buildier 4.7. While building, I notice that there are lot of features that work on a mobile app or a AIR app which actually dont on Web version.
It is actually not the problem with Flash/Adobe but instead it is a standard security issue that I have come across as a first notice when I deploy the application on server. Tricky part is it works perflectly fine when I test it locally. So here is the issue.
Issue
When any application(web) tries to call a REST API which is not in the same domain, excluding localhost, there should be an access granted on the target side to allow the request. We call this cross domain request. Obviously I don’t own the Dota2 Steam API server to change it :), so I was stuck with that issue.
Breaking my head
So as normal, I starting breaking my head with what the hell is wrong with my code and why is this not working on a standard webserver which is not localhost. After making cracks in my head, I came to realize that it is actually not my code by the server side who is not allowing the access and that too because this is not a local server. So, once I realize the problem, the solution was easy.
The solution (ointment to my headache)
The solution is just a security aspect which either has to be a cross domain mapping entry in Steam Dota2 Valve API server or a proxy at my end to enable the same.
So finally, I created a simple PHP proxy generic script which can be used to call the Steam Dota2 Web APIs.
For reference & open use, I have hosted the same on my server which you can use and also download and put on your local server if you want.
Two versions are there:
- XML Version -> Accepts a parameter “url” which is steam dota2 web api url with all parameters encoded and returns the output of the API in XML format [WebAPIProxy_JSON.php]
- JSON Version -> Accepts a parameter “url” which is steam dota2 web api url with all parameters encoded and returns the output of the API in JSON format. [WebAPIProxy_XML.php]
Feel free to ask any clarifications or share you views on developing apps around the Steam Dota2 API.
BTW, here is a link to iOS app [GameStats] and the facebook page [GameStats-FB]. Feel free to drop by.