C# Windows Phone 8 HttpClient没有';t响应所有Post数据
我想发布windwos phone 8的字符串数据,如下所示:C# Windows Phone 8 HttpClient没有';t响应所有Post数据,c#,windows-phone-8,http-post,C#,Windows Phone 8,Http Post,我想发布windwos phone 8的字符串数据,如下所示: using (var handler = new HttpClientHandler()) { if (handler.SupportsAutomaticDecompression) { handler.AutomaticDecompression = DecompressionMethods.GZip |
using (var handler = new HttpClientHandler())
{
if (handler.SupportsAutomaticDecompression)
{
handler.AutomaticDecompression = DecompressionMethods.GZip |
DecompressionMethods.Deflate;
}
using (var client = new HttpClient(handler))
{
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
var fromUrlEncodedContet =
new List<KeyValuePair<string, string>>()
{
new KeyValuePair<string, string>("aliasno1","01120"),
new KeyValuePair<string, string>("aliasno2", "89479"),
new KeyValuePair<string, string>("aliasno3", "1"),
new KeyValuePair<string, string>("myregion", "006"),
new KeyValuePair<string, string>("myregiontitle", "IZMIR")
};
using (var response = await client.PostAsync("http://m.kentkart.com/kws.php",
new FormUrlEncodedContent(fromUrlEncodedContet)))
{
if (response.IsSuccessStatusCode)
{
var data = response.Content.ReadAsStringAsync().Result;
}
}
}
}
使用(var handler=new-HttpClientHandler())
{
if(handler.supportsAutomatic解压)
{
handler.AutomaticDecompression=DecompressionMethods.GZip|
减压方法:放气;
}
使用(var客户端=新的HttpClient(处理程序))
{
client.DefaultRequestHeaders.Accept.Add(
新的MediaTypeWithQualityHeaderValue(“应用程序/json”);
变量fromUrlEncodedContet=
新名单()
{
新的KeyValuePair(“别名1”、“01120”),
新的KeyValuePair(“别名2”、“89479”),
新的KeyValuePair(“别名3”、“1”),
新的KeyValuePair(“myregion”、“006”),
新的KeyValuePair(“myregiontitle”、“IZMIR”)
};
使用(var response=wait client.PostAsync(“http://m.kentkart.com/kws.php",
新表单UrlEncodedContent(fromUrlEncodedContent)))
{
if(响应。IsSuccessStatusCode)
{
var data=response.Content.ReadAsStringAsync().Result;
}
}
}
}
当我点击按钮和断点数据时。我看到了这样的响应数据
{“time_webacc”:“1.6927719116211E-5!!”,“refreshCount”:0,“time_主机”:“4.0054321289062E-5!”,“servicetimediff”:5102,“时差”:“5102(主机)”}
我没有收到所有的数据。响应数据必须是
平衡器结果:“8,75”
费用金额:“10”
计费结果:“20140125152910”
func:“bs”
刷新次数:0
servicetimediff:354
时间主持人:“0.3545618057251!”
时间平衡状态:“0.0059030055999756!”
时间平衡:“0.34575796127319!”
时间:0.0028519630432129!!”
时差:“341(ws)/354(主机)”
usageAmt:“2”
USAGRESULT:“20140126123248”
我犯了一些错误,但我不明白我的错误在哪里。似乎您发布了错误的参数
using (var handler = new HttpClientHandler())
{
if (handler.SupportsAutomaticDecompression)
{
handler.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
}
using (var client = new HttpClient(handler))
{
client.DefaultRequestHeaders.Referrer = new Uri("http://m.kentkart.com/");
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
var fromUrlEncodedContet =
new List<KeyValuePair<string, string>>()
{
new KeyValuePair<string, string>("func","bs"),
new KeyValuePair<string, string>("val", "0112089479"),
new KeyValuePair<string, string>("myregiontitle", "Izmir"),
new KeyValuePair<string, string>("myregion", "006"),
};
using (var response = await client.PostAsync("http://m.kentkart.com/kws.php",
new FormUrlEncodedContent(fromUrlEncodedContet)))
{
if (response.IsSuccessStatusCode)
{
var data = await response.Content.ReadAsStringAsync();
dynamic obj = await JsonConvert.DeserializeObjectAsync(data);
var balance = Convert.ToDecimal((string)obj.balanceresult, CultureInfo.CreateSpecificCulture("tr-TR"));
}
}
}
}
使用(var handler=new-HttpClientHandler())
{
if(handler.supportsAutomatic解压)
{
handler.AutomaticDecompression=DecompressionMethods.GZip | DecompressionMethods.Deflate;
}
使用(var客户端=新的HttpClient(处理程序))
{
client.DefaultRequestHeaders.referer=新Uri(“http://m.kentkart.com/");
client.DefaultRequestHeaders.Accept.Add(
新的MediaTypeWithQualityHeaderValue(“应用程序/json”);
来自URLEncodedContet的变量=
新名单()
{
新的KeyValuePair(“func”、“bs”),
新的KeyValuePair(“val”,“0112089479”),
新的KeyValuePair(“myregiontitle”、“Izmir”),
新的KeyValuePair(“myregion”、“006”),
};
使用(var response=wait client.PostAsync(“http://m.kentkart.com/kws.php",
新表单UrlEncodedContent(fromUrlEncodedContent)))
{
if(响应。IsSuccessStatusCode)
{
var data=await response.Content.ReadAsStringAsync();
dynamic obj=await JsonConvert.DeserializeObjectAsync(数据);
var balance=Convert.ToDecimal((字符串)obj.balanceresult,CultureInfo.CreateSpecificCulture(“tr tr”);
}
}
}
}
顺便说一句:服务器将平衡器结果作为
“8,75”
返回。一个更正确的结果是8.75
(没有“
s)为什么你认为你的回复应该是你发布的,它不是有效的json、xml等?嗨,我正在使用浏览器中的开发工具(F12),然后选择“BAKIYE SORGULAMA”(左下)然后选择Izmir,然后输入01120-89479-1。我单击网络选项卡,看到如下响应。我需要使用balanceresult,ChargeAmThat您是否更改了任何代码?如果可能,您可以共享您的代码吗?也许我无法读取响应json