2
\$\begingroup\$

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#?

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

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 );
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .