public string GetAccessToken() { string JsCode2SessionUrl = string.Format(@"https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={0}&secret={1}", _appid, appsecret); JObject jObject = AjaxRequest.HttpGet(JsCode2SessionUrl, "").ToJsonObject <JObject>(); if (!jObject["access_token"].IsEmpty()) { return(jObject["access_token"].ToString()); } else { return(""); } }
string GeneralApiParam(string api_url, string api_params) { string resultContent = ""; try { api_url = api_url.EndsWith("?") ? api_url : api_url + "?"; api_params += string.Format("&appid={0}&appkey={1}", this.app_id, this.app_key); api_url += api_params; resultContent = AjaxRequest.HttpGet(api_url, ""); } catch (Exception ex) { LogHelper.WriteException("GeneralApiParam", ex); } return(resultContent); }
string GeneralApiParam(string api_url, string api_params) { string resultContent = ""; try { api_url = api_url.EndsWith("?") ? api_url : api_url + "?"; api_params += string.Format("&appKey={0}", this.dtk_appkey); api_url += api_params + "&sign=" + makeSign(api_params, this.dtk_appsecret); resultContent = AjaxRequest.HttpGet(api_url, ""); } catch (Exception ex) { LogHelper.WriteException("GeneralApiParam", ex); } return(resultContent); }
string GetApiResponse(string api_type, string paramJson, bool is_post = true) { string returnContent = ""; Dictionary <string, string> header = new Dictionary <string, string>(); //header.Add("Connection", "Upgrade "); header.Add("Upgrade", "HTTP/3.0 "); if (is_post) { returnContent = AjaxRequest.HttpPost(api_host + makeRequestParam(api_type, paramJson), paramJson, header, "", "application/json"); } else { returnContent = AjaxRequest.HttpGet(api_host + makeRequestParam(api_type, paramJson), paramJson); } return(returnContent); }