There are several ways to do this, you can check http://restfor.me/twitter and it will provide you the code from the RESTful documentation.
Essentially, with any authenticated call, you can follow this logic:
/// /// Executes an HTTP POST command and retrives the information. /// This function will automatically include a "source" parameter if the "Source" property is set. /// /// The URL to perform the POST operation /// The username to use with the request /// The password to use with the request /// The data to post /// The response of the request, or null if we got 404 or nothing. protected string ExecutePostCommand(string url, string userName, string password, string data) { WebRequest request = WebRequest.Create(url); request.ContentType = "application/x-www-form-urlencoded"; request.Method = "POST"; if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(password)) { request.Credentials = new NetworkCredential(userName, password); byte[] bytes = Encoding.UTF8.GetBytes(data); request.ContentLength = bytes.Length; using (Stream requestStream = request.GetRequestStream()) { requestStream.Write(bytes, 0, bytes.Length); using (WebResponse response = request.GetResponse()) { using (StreamReader reader = new StreamReader(response.GetResponseStream())) { return reader.ReadToEnd(); } } } } return null; }
source share