Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I would like to use Unity's WWW class to send a an HTTP request with POST data. So in my server, my PHP script can do something like

$number = $_POST["NUMBER"];

According to http://docs.unity3d.com/ScriptReference/WWW-ctor.html, I can provide a byte array in the constructor to represent such data.

I'm a bit puzzled - suppose I want to send a mapping from "NUMBER" to 200 - how would I create a byte array compatible with my PHP script in Unity C#?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Actually using the overloaded construct that take a WWWForm as second parameter, WWW class is automatically considered as an http post request.

Your code can be something like:

WWWForm form = new WWWForm();
form.AddField( "NUMBER", aNumber );

WWW postRequest = new WWW( server_url, form );
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.