如何在Windows Phone 8上发送简单的GET请求? [英] How do I send a simple GET request on Windows Phone 8?

查看:141
本文介绍了如何在Windows Phone 8上发送简单的GET请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Windows Phone 8中创建一个代码,用于以http://localhost/get_request.php格式向PHP文件发送基本GET请求?username = sops

我该怎么做?

I''m trying to create a code in Windows Phone 8 for sending a basic GET request to a PHP file in the format http://localhost/get_request.php?username=sops
How do I do this?

推荐答案

您好,



您可以使用类似下面的代码片段来实现实现它。

Hello,

You can use something like below code snippet to achieve it.
WebClient webClient = new WebClient();
// Register the callback
webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_DownloadStringCompleted);
webClient.DownloadStringAsync(new System.Uri(YOUR_URL));

void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
    if (e.Error == null)
    {
        updateSomething(e.result);
    }
}





这里 YOUR_URL 将是http://localhost/get_request.php?username = sops。



问候,



Here YOUR_URL will be "http://localhost/get_request.php?username=sops".

Regards,


这篇关于如何在Windows Phone 8上发送简单的GET请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆