/// <summary> /// 返回授权结果 /// </summary> /// <param name="Queryparams">获取授权token参数</param> /// <returns></returns> public string GetAccessTokenByAuthorized(List <Parameter> Queryparams) { string ResultStr = null; try { AuthModel Auths = null; //ResultStr = http.HttpGet(APIType.GetURL(TypeOption.MD_OAUTH2_ACCESSTOKEN), HttpUtility.NormalizeRequestParameters(Queryparams)); ResultStr = http.HttpGet(APIType.GetURL(TypeOption.MD_OAUTH2_ACCESSTOKEN), HttpUtility.NormalizeRequestParameters(Queryparams)); Auths = XmlSerializationHelper.XmlToObject <AuthModel>(ResultStr); if (Auths != null) { if (!string.IsNullOrEmpty(Auths.Error_Code)) { return(Auths.Error_Code); } return(!string.IsNullOrEmpty(Auths.access_token) ? Auths.access_token : string.Empty); } else { return("Error:10101"); } } catch (Exception ex) { throw new Exception(ex.Message.ToString() + ";" + APIType.GetURL(TypeOption.MD_OAUTH2_ACCESSTOKEN)); } }
//同步请求 public string SyncRequest(string Url, string HttpMethod, Parameter u_key, List <Parameter> ListParam, List <Parameter> ListFile) { if (ListParam == null) { ListParam = new List <Parameter>(); } if (u_key != null) { ListParam.Add(u_key); } string QueryStr = HttpUtility.NormalizeRequestParameters(ListParam); SyncHttp Http = new SyncHttp(); if (HttpMethod == "GET") { return(Http.HttpGet(Url, QueryStr)); } else if (ListFile == null || ListFile.Count == 0) { return(Http.HttpPost(Url, QueryStr)); } else { return(Http.oAuthWebRequestWithPic(Url, QueryStr, ListFile[0].Value, Path.GetFileName(ListFile[0].Value))); } }