- Home /
WWW Class behaves strangely on iOS
Hi,
I'm trying to execute a php script via the WWW-class in order to save highscores online. My code looks something like this:
WWW download = new WWW( "http://www.serverxy.net/game/script.php?cmd=scores" );
It works fine on PC and Mac, but on iOS devices there seems to be a problem: The WWW-class doesn't execute the php script defined in the URL. Instead it downloads the index.htm found on the root-level of the server.
Thanks in advance!
Answer by Simon Wittber · Feb 08, 2012 at 03:19 AM
The WWW class doesn't let you handle HTTP redirects yourself. UniWeb is a better HTTP api and will let you do this.
ouch, I lost quite some time on this,as unity simply hangs without any notice or error as far my testing goes! thanks Simon!
Answer by Dreamora · Dec 26, 2011 at 05:08 PM
The line there does not execute anything like that. Could you please post the rest of the code so its ensured you correctly execute WWW etc? (I ask cause I've seen people using WWW outside of coroutines which at times can work on the desktop or webplayer but will always fail on mobile where WWW will never immediately return - WWW always must be in coroutines and yield until they are done)
Just to mention that in case you search in other places: the WWW call never executes the php, its the apache server that would do it, all that WWW does is tell the server to do that and then it will return the echo that your PHP outputs, if there is one. But thats only a detail and not of relevance in this case as it works on PC / Mac
Answer by davedev · Jan 19, 2012 at 01:45 PM
The call is probably getting redirected to "http://index.htm" because there's something wrong with "http://www.serverxy.net/game/script.php?cmd=scores" or maybe iOS mangles the url somehow, but the server probably gets a url for an invalid page and redirects it to index.htm. Does "http://www.serverxy.net/game/script.php?cmd=scores" work from the browser? Do you have access to the server logs that you can look at? Try a test php file at simpler url and see if that works.