JS External Interface calls, security violations??

4 posts

Flag Post

Hi I’ve found a few posts on forums relating to this, but the response has always been that kongregate has a bug on there side which would be fixed within a week or two. Also these posts were all a few months ago though.

I came accross these problems when attempting to call the REST api from within as3, however I have attempted this a few ways with no luck.

Attempt one:

I used this…..

urlLoader = new URLLoader();
urlRequest = new URLRequest(“http://www.kongregate.com/api/user_info.json?username=rlthomas_london&friends=true”);
urlLoader.addEventListener(Event.COMPLETE, handleResponse);
urlLoader.load(urlRequest);

In which I recieved this error:

Error #2044: Unhandled securityError:. text=Error #2048: Security sandbox violation: http://chat.kongregate.com/gamez/0013/2307/preview/KongregateTest.swf?kongregate_game_version=1325675276 cannot load data from http://www.kongregate.com/api/user_info.json?username=rlthomas_london&friends=true.

So no luck there.

Attempt two:

JS Bridge…..

using embedded java script in CDATA to perform a simple alert box popup

SecurityError: Error #2060: Security sandbox violation: ExternalInterface caller http://chat.kongregate.com/gamez/0013/2307/preview/KongregateTest.swf?kongregate_game_version=1325675625 cannot access http://www.kongregate.com/games/rlthomas_london/kongregateapitests_preview.

In this attempt I built a JS Bridge but before even asking the bridge to perform the call I attempted to just show an alert box and recieved this error due to the allowscriptaccess parameter automatically being set to “never”.

It’s really annoying that i can’t use the REST API from within as3. Both these attempts worked fine when tested locally, could even load my avatar image into the swf to be displayed. This sort of stuff would be usefull when creating ville’esk style games where you have a friend list and can see each others avatars also work out who’s peoples friends are etc, etc.

Is there any known work around??

help would be very much apreciated on this matter please, please :)
Thankyou

-R Thomas

 
Flag Post

When loading user info, make sure you are pulling from api.kongregate.com and not www.kongregate.com. Using the former, no security errors will be thrown.

 
Flag Post

You absoloute legend, works perfectly now, thanks again!!!! :)

 
Flag Post

Hi…it does not work for me.- do you have any suggestion? i cannot retrieve user_info with JS