How do I call JSON from the Kong API with Unity?

7 posts

Flag Post

I am using the WWW class to get JSON back from the Kong API.

I keep getting the dreaded ‘No valid crossdomain policy available to allow access’ error, and since I can’t put my own crossdomain.xml policy file on Kong’s servers, how the heck do I call JSON on the KONG API?

Any advice is appreciated.

Thanks

 
Flag Post

Try api.kongregate.com for all your requests. Which JSON feed are you using?

 
Flag Post

Thank you, using api works. I was using http://www.kongregate.com/api/authenticate.json

 
Flag Post

I really hope you aren’t using that API clientside. What language are you using on your server that needs a crossdomain.xm?

 
Flag Post

I’m a bit confused as to what should be called client side, and what should be called server side.

My view is that anything sensitive such as authentication or kreds/unlocks should be made server side, with a callback to the callback url.
But then on the authentication side of things, you have the kongregate.services.getGameAuthToken(); which is a client side call.

Can you explain this a bit, I find it a bit confusing.

Thanks

 
Flag Post

A good rule is “Does it require your Game API key?” If so, that must go on serverside. Never, ever expose your api key to the client.

A game auth token is a different from your API key. Users shouldn’t share these, but if the user sees theirs then it isn’t bad.

 
Flag Post

I have been searching for information for ages now how i would make calls to the rest api with my unity web player game that is hosted in an iframe. I get crossdomain problems if i use the www class inside unity and i am just unsure at the approach i should take when trying to use items, please
give me some input :)

At the moment i have the API loaded in the page via javascript and i do ExternalCall and ExternalEval to set up functions and call the client side api to login and fetch useritems etc etc. But actually using the item feels like a problem, first i need to reach the API and tell it i want to use an item that is the problem above, then i specify the callback url to my a php script i write? Or should the callback function be directed to the game page i am currently in?