Esempio n. 1
0
        public T DoPost <T>(IWxApiPostRequest <T> request) where T : WxApiBaseResult
        {
            // request.GetUrlParameters()

            string realServerUrl = request.ApiUrl;

            WebUtils webUtils = new WebUtils();

            string postData = null;

            if (request.PostDataTpye == WxPostDataType.Text)
            {
                postData = request.PostData.ToString();
            }
            else if (request.PostDataTpye == WxPostDataType.Json)
            {
                postData = JsonConvert.SerializeObject(request.PostData);
            }

            log.InfoFormat("WeiXinSdk-Post->{0}", postData);
            responseString = webUtils.DoPost(realServerUrl, request.GetUrlParameters(), postData);
            log.InfoFormat("WeiXinSdk-Result->{0}", responseString);
            T rsp = JsonConvert.DeserializeObject <T>(responseString);


            return(rsp);
        }
Esempio n. 2
0
        public T DoPost <T>(IWxApiPostRequest <T> request) where T : WxApiBaseResult
        {
            string   realServerUrl = GetServerUrl(this.serverUrl, request.ApiName);
            WebUtils webUtils      = new WebUtils();

            string postData = null;

            if (request.PostDataTpye == WxPostDataType.Text)
            {
                postData = request.PostData.ToString();
            }
            else if (request.PostDataTpye == WxPostDataType.Json)
            {
                postData = JsonConvert.SerializeObject(request.PostData);
            }


            string body = webUtils.DoPost(realServerUrl, request.GetUrlParameters(), postData, null);
            T      rsp  = JsonConvert.DeserializeObject <T>(body);


            return(rsp);
        }