SaveRequest() public static méthode

public static SaveRequest ( object>.Dictionary dict ) : void
dict object>.Dictionary
Résultat void
Exemple #1
0
        public WWW POST(int type, string url, Dictionary <string, object> post)
        {
//			WWWForm form = new WWWForm();
//			StringBuilder sb = new StringBuilder ();
            if (!post.ContainsKey(XsollaApiConst.ACCESS_TOKEN) && !post.ContainsKey("project") && !post.ContainsKey("access_data") && baseParams != null)
            {
                foreach (KeyValuePair <string, object> kv in baseParams)
                {
                    post.Add(kv.Key, kv.Value);                     //.Add (XsollaApiConst.ACCESS_TOKEN, _accessToken);
                }
                if (!post.ContainsKey(XsollaApiConst.ACCESS_TOKEN) && !baseParams.ContainsKey(XsollaApiConst.ACCESS_TOKEN) && (_accessToken != ""))
                {
                    post.Add(XsollaApiConst.ACCESS_TOKEN, _accessToken);
                }
            }
            if (type == DIRECTPAYMENT_STATUS)
            {
                TransactionHelper.SaveRequest(post);
            }
            if (!post.ContainsKey("alternative_platform"))
            {
                post.Add("alternative_platform", "unity/" + SDK_VERSION);
            }

//			foreach(KeyValuePair<string,object> post_arg in post)
//			{
//				string argValue = post_arg.Value != null ? post_arg.Value.ToString() : "";
//				sb.Append(post_arg.Key).Append("=").Append(argValue).Append("&");
//				form.AddField(post_arg.Key, argValue);
//
//			}

            if (httpreq == null)
            {
                httpreq = GameObject.Find(HttpTlsRequest.loaderGameObjName).GetComponent <HttpTlsRequest>();
            }

            StartCoroutine(httpreq.Request(url, post, (value) => ProcessingRequestResult(type, value, post)));

//			Debug.Log (url);
//			Debug.Log (sb.ToString());
//			WWW www = new WWW(url, form);
//			StartCoroutine(WaitForRequest(type, www, post));
            return(null);
        }
        public IEnumerator POST(int type, string url, Dictionary <string, object> post)
        {
            WWWForm       form = new WWWForm();
            StringBuilder sb   = new StringBuilder();

            if (!post.ContainsKey(XsollaApiConst.ACCESS_TOKEN) && !post.ContainsKey("project") && !post.ContainsKey("access_data") && baseParams != null)
            {
                foreach (KeyValuePair <string, object> kv in baseParams)
                {
                    post.Add(kv.Key, kv.Value);
                }
                if (!post.ContainsKey(XsollaApiConst.ACCESS_TOKEN) && !baseParams.ContainsKey(XsollaApiConst.ACCESS_TOKEN) && (_accessToken != ""))
                {
                    post.Add(XsollaApiConst.ACCESS_TOKEN, _accessToken);
                }
            }
            if (type == DIRECTPAYMENT_STATUS)
            {
                TransactionHelper.SaveRequest(post);
            }
            if (!post.ContainsKey("alternative_platform"))
            {
                post.Add("alternative_platform", "unity/" + SDK_VERSION);
            }

            foreach (KeyValuePair <string, object> post_arg in post)
            {
                string argValue = post_arg.Value != null?post_arg.Value.ToString() : "";

                sb.Append(post_arg.Key).Append("=").Append(argValue).Append("&");
                form.AddField(post_arg.Key, argValue);
            }

            Debug.Log(url);
            Debug.Log(sb.ToString());
            WWW www = new WWW(url, form);

            yield return(StartCoroutine(WaitForRequest(type, www, post)));
        }