Advertisement
Guest User

Untitled

a guest
Dec 28th, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.50 KB | None | 0 0
  1. using System;
  2. using System.Threading.Tasks;
  3. using System.Net;
  4. using System.IO;
  5. using System.Text;
  6.  
  7. namespace MyNamespace {
  8.     public class MyActivity {
  9.        
  10.         private async Task<bool> Request () {
  11.  
  12.             string url = "http://noigan.it/wp-admin/admin-ajax.php";
  13.  
  14.             HttpWebRequest request = (HttpWebRequest)WebRequest.Create (new Uri(url));
  15.             request.ContentType = "application/x-www-form-urlencoded; charset=utf-8";
  16.             request.Headers.Add("Cookie", "wordpress_27e6e5f71b0ae47d93d1b1eace534cb8=mirko.diciaccio%40mobilesoft.it%7C1484125300%7CkcjNDhhORFpwtI3hMVxnXYDtBPTPcFBIgebbZvvAiBb%7Cbf9d46ad01f08c5459c99f16397872d54cb97b5b6295bf59d3b9c452289c05e0; PHPSESSID=arhns73eqttfoi2o4q0mhfl585; wordpress_logged_in_27e6e5f71b0ae47d93d1b1eace534cb8=mirko.diciaccio%40mobilesoft.it%7C1484125300%7CkcjNDhhORFpwtI3hMVxnXYDtBPTPcFBIgebbZvvAiBb%7C2c0f3473fdf8693675d2ce1b9d78ce1625525630230771489ed55c4513ce79c6");
  17.            
  18.             request.Method = "POST";
  19.            
  20.             string postData = "action=na_login&username=mirko.diciaccio%40mobilesoft.it&password=test_password";
  21.             ASCIIEncoding encoding = new ASCIIEncoding ();
  22.             byte[] byte1 = encoding.GetBytes (postData);
  23.             request.ContentLength = byte1.Length;
  24.             Stream newStream = request.GetRequestStream ();
  25.             newStream.Write (byte1, 0, byte1.Length);
  26.             newStream.Close ();
  27.            
  28.             using (WebResponse response = await request.GetResponseAsync ()) {
  29.                 using (Stream stream = response.GetResponseStream ()) {
  30.                     return true;
  31.                     //process the response
  32.                 }
  33.             }
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement