private IEnumerator PostData(GrdNetworkEventHandler callback, string action, Dictionary <string, string> pars = null) { WWWForm wwwForm = new WWWForm(); foreach (string key in pars.Keys) { wwwForm.AddField(key, pars[key]); } wwwForm.AddField("api_id", apiId); wwwForm.AddField("api_key", GetApiKey()); if (token.Length > 0) { wwwForm.AddField("token", token); } WWW www = new WWW(apiUrl + action, wwwForm); yield return(www); string data = www.text; int ipos = data.IndexOf("{"); if (ipos > 0) { data = data.Substring(ipos); } callback(data); }
private IEnumerator GetData(GrdNetworkEventHandler callback, string action, Dictionary <string, string> pars = null) { string url = apiUrl + action; if (pars != null && pars.Count > 0) { url = url + "/api_id=" + apiId + "&api_key=" + GetApiKey(); if (token.Length > 0) { url += "&token=" + token; } foreach (string key in pars.Keys) { url += "&" + key + "=" + WWW.EscapeURL(pars[key]); } } WWW www = new WWW(url); yield return(www); string data = www.text; int ipos = data.IndexOf("{"); if (ipos > 0) { data = data.Substring(ipos); } callback(data); }
public void Get(GrdNetworkEventHandler callback, string action, Dictionary <string, string> pars = null) { StartCoroutine(GetData(callback, action, pars)); }