public partial class Login : PhoneApplicationPage { public Login() { InitializeComponent(); } private void Login_Click(object sender, RoutedEventArgs e) { SendRequest(Box_email.Text, PasswordBox.Password); } public void SendRequest(String email, String mdp) { // Create a new HttpWebRequest object. HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://19.334.35.55/eip/api/web/app.php/oauth/v2/token?"); string _url = "http://19.334.35.55/eip/api/web/app.php/oauth/v2/token?"; string _email = "Username=" + email; string _mdp = "password=" + mdp; request.ContentType = _url + _email + _mdp; request.Method = "GET"; MessageBox.Show("point A debug"); request.BeginGetResponse(new AsyncCallback(GetResponseCallback), request); allDone.WaitOne(); } private void GetResponseCallback(IAsyncResult asynchronousResult) { // Dispatcher.BeginInvoke(() => // { // MessageBox.Show("inside get response"); // }); HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState; if (request != null) { try { // End the operation HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asynchronousResult); Stream streamResponse = response.GetResponseStream(); StreamReader streamRead = new StreamReader(streamResponse); string responseString = streamRead.ReadToEnd(); Console.WriteLine(responseString); // Close the stream object streamResponse.Close(); streamRead.Close(); // Release the HttpWebResponse response.Close(); allDone.Set(); } catch (WebException e) { MessageBox.Show("probleme"); return; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)