Exemplo n.º 1
0
        public IEnumerator POST <T> (string url, Parameters.ITwitterParameters parameters, Action <T> callback)
        {
            WWWForm wwwForm = new WWWForm();

            parameters.Queries.ToList().ForEach(x =>
            {
                wwwForm.AddField(x.Key, x.Value);
            });

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

            headers.Add("Authorization", oAuth.GetAuthorizationHeader(url, "POST", parameters));

            WWW www = new WWW(url, wwwForm.data, headers);

            yield return(www);

            try
            {
                callback(JsonConvert.DeserializeObject <T> (www.text));
            }
            catch (Exception e)
            {
                Debug.Log(www.text);
                Debug.Log(e);
            }
        }
Exemplo n.º 2
0
        public IEnumerator GET <T> (string url, Parameters.ITwitterParameters parameters, Action <T> callback)
        {
            url += parameters.ComposeQueryString();

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

            headers.Add("Authorization", oAuth.GetAuthorizationHeader(url, "GET", parameters));

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

            yield return(www);

            try {
                callback(JsonConvert.DeserializeObject <T> (www.text));
            }
            catch (Exception e)
            {
                Debug.Log(www.text);
                Debug.Log(e);
            }
        }