Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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 10-Mar-13 9:35am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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);
    }
}
 
Here YOUR_URL will be "http://localhost/get_request.php?username=sops".
 
Regards,
  Permalink  
v2
Comments
CoolSops at 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 at 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)

  Print Answers RSS
0 OriginalGriff 390
1 Jochen Arndt 150
2 Richard MacCutchan 135
3 DamithSL 95
4 Garth J Lancaster 90
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,260


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 11 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100