IEnumerator Get(string url, Dictionary<string, string> getData) {
string param = null;
if (getData != null) {
param = "?";
int count = getData.Count;
int index = 0;
foreach (KeyValuePair<string, string> kvp in getData) {
if (index < count - 1) {
param += kvp.Key + "=" + kvp.Value + "&";
}
else {
param += kvp.Key + "=" + kvp.Value;
}
index++;
}
}
param = WWW.EscapeURL(param);
WWW www = new WWW(url + param);
yield return www;
if (!string.IsNullOrEmpty(www.error)) {
Debug.Log(www.error);
} else {
Debug.Log(www.text);
}
}
IEnumerator Post(string url, Dictionary<string, string> postData) {
WWWForm wwwForm = new WWWForm();
foreach (KeyValuePair<string, string> kvp in postData) {
wwwForm.AddField(kvp.Key, kvp.Value);
}
WWW www = new WWW(saveUrl, wwwForm);
yield return www;
if (!string.IsNullOrEmpty(www.error)) {
Debug.Log(www.error);
}
else {
Debug.Log(www.text);
}
}