Hello
I used the WWWForm call in the following manner in order
to post my parameters to a web site.
form = new WWWForm()
form.AddField(“userId”,“”+_userId);
form.AddField(“time”,time);
link = new WWW(“http://MyURLaddress.com”, form);
if (link.error) {
Debug.Log( "Error uploading: " + link.error );
}else {
Debug.Log(“Finished uploading data”);
}
I was expecting Unity to launch a new browser window sending my form attributes, instead I received "Finished uploading data and my form parameters never reached the URL destination for the server to do a POST on. Am I missing something.
Thanks
Mike
You are using the wrong method if you wish a browser window to be opened.
Using:
Application.OpenURL(“http://URLtoyoursite.com”);
will work however it doesn’t allow you to send POST data.
If you want a browser window to open, the then WWW class isn’t the route to go.
If you simply want to do a POST from within Unity, you’re 90% there.
You need to yield while the WWW call is made.
form = new WWWForm()
form.AddField("userId",""+_userId);
form.AddField("time",time);
link = new WWW("http://MyURLaddress.com", form);
// this is what you need to add
yield link;
if (link.error) {
Debug.Log( "Error uploading: " + link.error );
}else {
Debug.Log("Finished uploading data");
}