public bool connect() { var num = ConvertDateTimeInt(DateTime.Now); var md5SignValue = getMD5SignValue(new Dictionary <string, string> { { "appkey", appKey }, { "timeStamp", string.Concat(num) }, { "masterSecret", masterSecret } }); var paramData = new Dictionary <string, object> { { "action", nameof(connect) }, { "appkey", appKey }, { "timeStamp", num }, { "sign", md5SignValue }, { "version", GtConfig.getSDKVersion() } }; JsonConvert.SerializeObject(paramData); var input = httpPost(host, paramData, false); var dictionary = JsonConvert.DeserializeObject <Dictionary <string, object> >(input); if (input.IndexOf("success") <= -1) { throw new Exception("appKey or masterSecret is auth failed."); } AuthToken = (string)dictionary["authtoken"]; return(true); }
public void close() { httpPostJSON(new Dictionary <string, object> { { "action", nameof(close) }, { "appkey", appKey }, { "version", GtConfig.getSDKVersion() }, { "authToken", AuthToken } }); }
public string httpPostJSON(string url, Dictionary <string, object> postData, bool gzip) { postData.Add("version", GtConfig.getSDKVersion()); JsonConvert.SerializeObject(postData); postData.Add("authToken", AuthToken); var input = httpPost(url, postData, gzip); if (string.IsNullOrEmpty(input)) { if (postData.ContainsKey("requestId")) { throw new RequestException((string)postData["requestId"], "Http request exception,address is " + url); } return(input); } if (input.IndexOf("sign_error") > -1) { if (connect()) { postData.Remove("authToken"); postData.Add("authToken", AuthToken); return(httpPost(url, postData, gzip)); } } else if (input.IndexOf("domain_error") > -1) { var dictionary = JsonConvert.DeserializeObject <Dictionary <string, object> >(input); appkeyUrlList.Add(appKey, CastToList(((JArray)dictionary["osList"]).ToObject <List <dynamic> >())); dynamicGetFastest(null); return(httpPost(host, postData, gzip)); } return(input); }