async public void sendGet(string uriStr, Dictionary <string, string> dic, finishd delegatefi, err e) { string apendStr = "?"; foreach (string key in dic.Keys) { string value = dic[key]; apendStr += key + "=" + value + "&"; } apendStr = apendStr.Remove(apendStr.Length - 1, 1); uriStr += apendStr; //var content = new HttpFormUrlEncodedContent(dic); Uri uri = new Uri(uriStr); try { HttpResponseMessage message = await client.GetAsync(uri); if (message.StatusCode == HttpStatusCode.Ok && message != null) { JsonObject json = JsonObject.Parse(message.Content.ToString()); delegatefi(json); } else { e("请求失败"); } } catch { e("链接错误"); } }
async public void sendPOST(string uriStr, Dictionary <string, string> dic, finishd delegatefi, err e) { // Dictionary<string, string> dic = new Dictionary<string, string>(); var content = new HttpFormUrlEncodedContent(dic); Uri uri = new Uri(uriStr); try { HttpResponseMessage message = await client.PostAsync(uri, content); if (message.StatusCode == HttpStatusCode.Ok && message != null) { JsonObject json = JsonObject.Parse(message.Content.ToString()); delegatefi(json); } else { e("请求失败"); } } catch { e("链接错误"); } }