Ben olayı gönderdikten sonraWebClient alternatif?
WebClient client = new WebClient();
client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
client.DownloadStringAsync(url);
yapabilirsiniz WebClient'a ile Windows Phone 8 ve Android HttpClient Yahoo veri getirmek için WebClient
kullanın;
StringReader stream = new StringReader(e.Result)
XmlReader reader = XmlReader.Create(stream);
reader.ReadToFollowing("yweather:atmosphere");
string humidty = reader.MoveToAttribute("humidity");
ancak Windows 8 RT içinde
böyle bir şey yoktur.nasıl aşağıdaki verileri getirebilir ? Sadece
public async static Task<string> GetHttpResponse(string url)
{
var request = new HttpRequestMessage(HttpMethod.Get, url);
request.Headers.Add("UserAgent", "Windows 8 app client");
var client = new HttpClient();
var response = await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead);
if (response.IsSuccessStatusCode)
return await response.Content.ReadAsStringAsync();
else
throw new Exception("Error connecting to " + url +" ! Status: " + response.StatusCode);
}
basit versiyonu olacaktır::>http://weather.yahooapis.com/forecastrss?w=2343732&u=c
"HttpClient" e baktınız mı? –