private IEnumerator MakeRequestEnumerator(string method, string url, Dictionary <string, object> data, RequestReadyDelegate readyDelegate, RequestFailedDelegate failedDelegate)
    {
        if (data == null)
        {
            data = new Dictionary <string, object>();
        }

        if (url.IndexOf("http") != 0)
        {
            if (url.IndexOf("/") != 0)
            {
                url = "/" + url;
            }

            url = "https://api.everyplay.com" + url;
        }

        method = method.ToLower();

        Hashtable headers = new Hashtable();

        string accessToken = AccessToken();

        if (accessToken != null)
        {
            headers["Authorization"] = "Bearer " + accessToken;
        }
        else
        {
            if (url.IndexOf("client_id") == -1)
            {
                if (url.IndexOf("?") == -1)
                {
                    url += "?";
                }
                else
                {
                    url += "&";
                }
                url += "client_id=" + clientId;
            }
        }

        data.Add("_method", method);


        string dataString = Json.Serialize(data);

        byte[] dataArray = System.Text.Encoding.UTF8.GetBytes(dataString);

        headers["Accept"]         = "application/json";
        headers["Content-Type"]   = "application/json";
        headers["Data-Type"]      = "json";
        headers["Content-Length"] = dataArray.Length;

        WWW www = new WWW(url, dataArray, headers);

        yield return(www);

        if (!string.IsNullOrEmpty(www.error) && failedDelegate != null)
        {
            failedDelegate("Everyplay error: " + www.error);
        }
        else if (string.IsNullOrEmpty(www.error) && readyDelegate != null)
        {
            readyDelegate(www.text);
        }
    }
 public void MakeRequest(string method, string url, Dictionary <string, object> data, RequestReadyDelegate readyDelegate, RequestFailedDelegate failedDelegate)
 {
     StartCoroutine(MakeRequestEnumerator(method, url, data, readyDelegate, failedDelegate));
 }