Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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?
Posted

1 solution

Hello,

You can use something like below code snippet to achieve it.
C#
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);
    }
}


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

Regards,
 
Share this answer
 
v2
Comments
CoolSops 10-Mar-13 19:19pm    
Is the "GetResponseAsync" method present in Windows Phone 8 API? I tried looking it for at http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207211(v=vs.105).aspx but couldn't find any. Did you import any additional libraries? Sorry, if my question sounds like a total noob but I'm used to programming with Java and not with .Net
Prasad Khandekar 11-Mar-13 3:59am    
Hello,

Updated the sample. Instead of HttpWebRequest it now uses WebClient which is much easy to work with.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900