Example #1
0
    /*
     * USER MISC TEST
     */
    IEnumerator MiscUser()
    {
        string url = "test_user_misc";
        // とりあえず空データ
        UpdateUserPost sendData = new UpdateUserPost();

        Dictionary <string, string> headers = new Dictionary <string, string>();

        headers["Content-Type"] = "application/json; charset=utf-8";

        string dataStr = JsonMapper.ToJson(sendData);

        Debug.Log(dataStr);

        byte[] data = System.Text.Encoding.UTF8.GetBytes(dataStr);


        using (WWW www = new WWW(HOST + url, data, headers)) {
            yield return(www);

            if (!string.IsNullOrEmpty(www.error))
            {
                Debug.Log("error:" + www.error);
                yield break;
            }
            Debug.Log("text:" + www.text);
        }
    }
Example #2
0
    /////////////////////////////////////////////////

    /*
     * USER UPDATE
     */
    IEnumerator UpdateUser()
    {
        string         url      = "test_user_update";
        UpdateUserPost sendData = new UpdateUserPost();

        sendData.Id        = 2;
        sendData.AddScore += 123;

        Dictionary <string, string> headers = new Dictionary <string, string>();

        headers["Content-Type"] = "application/json; charset=utf-8";

        string dataStr = JsonMapper.ToJson(sendData);

        Debug.Log(dataStr);

        byte[] data = System.Text.Encoding.UTF8.GetBytes(dataStr);


        using (WWW www = new WWW(HOST + url, data, headers)) {
            yield return(www);

            if (!string.IsNullOrEmpty(www.error))
            {
                Debug.Log("error:" + www.error);
                yield break;
            }
            //Debug.Log ("text:" + www.text);
            RecieveUser user = JsonMapper.ToObject <RecieveUser>(www.text);
            Debug.Log("RECIEVE Id:" + user.Id + "Name:" + user.Name + ", Score:" + user.Score);
        }
    }