// string data = "{\"uid\":515,\"timestamp\":\"2018 - 5 - 25 19:05:00\",\"encode\":\"3A19E9D6EAFF2FA9160ED6981EB522E1\"}"; /// <summary> /// 與適當性認證相關的 ...
// string data = "{\"uid\":515,\"timestamp\":\"2018 - 5 - 25 19:05:00\",\"encode\":\"3A19E9D6EAFF2FA9160ED6981EB522E1\"}"; /// <summary> /// 與適當性認證相關的客戶信息 XXXXXXXXXXXXXXX /// </summary> /// <param name="pid"> aid(管理人的id)</param> public async static void GetSpeUser(string aid) { if (string.IsNullOrEmpty(aid)) return; string date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); var encode = string.Format("aid:{0},timestamp:{1},Appid:{2},Appkey:{3}", aid, date, Configs.SimpleBeautifulAppid, Configs.SimpleBeautifulAppkey).ToUpper(); encode = GeneralHelper.CreateMD5(encode); Models.ManUserModel model = new Models.ManUserModel(); model.aid = aid; model.timestamp = date; model.encode = encode; var handler = new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.GZip }; using (var client = new HttpClient(handler)) { AppUser appuser = new AppUser(); var content = new StringContent(JsonConvert.SerializeObject(model)); content.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); var url = string.Format("{0}/{1}", "http://qsl.hffss.com/xem", "getSpeUser"); client.Timeout = TimeSpan.FromSeconds(100); var response = await client.PostAsync(url, content); //確保HTTP成功狀態值 response.EnsureSuccessStatusCode(); //await非同步讀取最後的JSON(註意此時gzip已經被自動解壓縮了,因為上面的AutomaticDecompression = DecompressionMethods.GZip) var responseString = await response.Content.ReadAsStringAsync(); //Console.WriteLine(await response.Content.ReadAsStringAsync()); //var response = await client.PostAsync(url, content); //Stream stream = await response.Content.ReadAsStreamAsync(); //StreamReader readStream = new StreamReader(stream, Encoding.UTF8); //string SourceCode = readStream.ReadToEnd(); //var response = await client.PostAsync(url, content); //var responseString = await response.Content.ReadAsStringAsync(); //var list = JsonConvert.DeserializeObject<AppUser>(responseString); } }