• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

make a URLRequest to an external server

New Here ,
Jul 18, 2018 Jul 18, 2018

Copy link to clipboard

Copied

I am having an awful time trying to figure out why I am getting Sandbox Security errors when making a request from our game host server to our gamesparks server.

trying to ask gamesparks for a method we made for user name generation

private const GET_NAMES:String = "https://E300018ZDdAx.preview.gamesparks.net/callback/E300018ZDdAx/generateName/YR5w9F53GYeMsP8LTBqij...";

private function getNames():void

{

var postVars:URLVariables = new URLVariables();

postVars.count = 10

var req:URLRequest = new URLRequest(GET_NAMES);

req.method = URLRequestMethod.POST;

req.data = postVars;

var loader:URLLoader = new URLLoader(req);

loader.dataFormat=URLLoaderDataFormat.VARIABLES;

loader.addEventListener(Event.COMPLETE,check);

loader.addEventListener(IOErrorEvent.IO_ERROR, onError);

loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);

loader.load(req);

}

protected function onSecurityError(event:SecurityErrorEvent):void

{

shellApi.logWWW(event.errorID, event.text);

removeEventHandling(event.target as URLLoader);

}

protected function onError(event:IOErrorEvent):void

{

shellApi.logWWW(event.errorID, event.text);

removeEventHandling(event.target as URLLoader);

}

protected function check(event:Event):void

{

trace(event.data);

removeEventHandling(event.target as URLLoader);

}

private function removeEventHandling(loader:URLLoader):void

{

loader.removeEventListener(Event.COMPLETE, check);

loader.removeEventListener(IOErrorEvent.IO_ERROR, onError);

loader.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);

}

in my searches everything people keep saying its due to our crossdomain.xml, but the game sparks crossdomain.xml we have seems pretty open

https://e300018zddax.preview.gamesparks.net/crossdomain.xml

<cross-domain-policy>

<allow-access-from domain="*" to-ports="843, 443, 80, 8081, 8080, 8082"/>

</cross-domain-policy>

they also say stuff like Security.loadPolicyFile(url);, but from what i understand that is only useful if the code is contained in the swf that is on the external game sparks server, but the request i am making is not to load a swf, but to get a json string from gamesparks.

I really don't have a good server background, so assume I know nothing and i am making this up as i go along, because i am.

thanks in advance.

Views

966

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 20, 2018 Jul 20, 2018

Copy link to clipboard

Copied

LATEST

Usually starting with the absolute basics eliminates anything obvious but you should mention in what context are you coding this. I see shellApi so it appears to be wrapped in something or possibly AIR. If you're running a SWF in a browser or something else, please list out how it is contained.

Always check endpoints with any online resource or app (many available). You should make the request and validate the results, listing anything here that might be important. It's a straight forward POST request. However you mentioned you expect the response as JSON text and are using URLLoaderDataFormat.VARIABLES which expects a URL encoded string. More info here:

URLLoaderDataFormat - Adobe ActionScript® 3 (AS3 ) API Reference

I'd also have to ask the obvious. The ports covered are the port the server expects a HTTP request from on the GameSparks side, correct?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines