Home

2014. 12. 25.

[Unity] JSON Type 웹서버로 POST


[Unity] JSON Type 웹서버로 POST

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
IEnumerator PostJSonData(string jsonData)
{
    string url = "www.myurl.com";
    byte[] data = Encoding.UTF8.GetBytes(jsonData.ToCharArray());
    Hashtable header = new Hashtable();
    header.Add("Content-Type""text/json");
    header.Add("Content-Length", data.Length);
    WWW www = new WWW(url, data, headers);
    yield return www;
    if (www.isDone && www.error == null)
    {
        Debug.Log("www Result: " + www.text);
    }
    else
    {
        Debug.Log("error : " + www.error);
    }
}
cs