public void POST(string url, Dictionary <string, object> requestData, RequestListenerDelegate onComplete) { SessionData sessionData = SessionData.GetInstance(); m_requestURL = url; m_requestData = requestData; m_request = new WWWForm(); m_resultListener = onComplete; if (requestData != null) { foreach (string fieldName in requestData.Keys) { string fieldValue = requestData[fieldName].ToString(); m_request.AddField(fieldName, fieldValue); } } //###HACK: // For some reason you can't add a key-value pair directly to the request header // You have to clone it, and add the cookie to that instead Hashtable headers = m_request.headers.Clone() as Hashtable; if (sessionData.Cookie.Length > 0) { headers.Add("Cookie", SessionData.GetInstance().Cookie); } m_loader = new WWW(m_requestURL, m_request.data, headers); Debug.Log("Sending POST request"); StartCoroutine(ExecuteRequest()); }
public void GET(string url, RequestListenerDelegate onComplete) { m_requestURL = url; m_requestData = null; m_request = null; m_resultListener = onComplete; m_loader = new WWW(m_requestURL); Debug.Log("Sending POST request"); StartCoroutine(ExecuteRequest()); }