public string POST(string url, string username,string password, string postParams)
{
//Our getVars, to test the get of our php.
//We can get a page without any of these vars too though.
//string getVars = "?var1=test1&var2=test2";
//Initialization, we use localhost, change if applicable
HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(url);
WebReq.UserAgent = GetRndUserAgent();
string Credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(username + ":" + password));
WebReq.Method = "POST";
WebReq.ContentType = "application/xml";
WebReq.AllowWriteStreamBuffering = true;
WebReq.Headers.Add("Authorization", "Basic " + Credentials);
WebReq.ServicePoint.Expect100Continue = false;
// string postParams = "name=some sort of value";
if (postParams != string.Empty)
{
byte[] buffer = ASCIIEncoding.UTF8.GetBytes(postParams);
WebReq.ContentLength = buffer.Length;
using (Stream writer = WebReq.GetRequestStream())
{
writer.Write(buffer, 0, buffer.Length);
}
}
//From here on, it's all the same as above.
HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();
//Let's show some information about the response
//_log(WebResp.StatusCode.ToString());
//_log(WebResp.Server);
//Now, we read the response (the string), and output it.
Stream Answer = WebResp.GetResponseStream();
StreamReader _Answer = new StreamReader(Answer);
return _Answer.ReadToEnd();
}
Sunday
csharp post form data
Subscribe to:
Post Comments (Atom)
test smtp server with powershell
Send-MailMessage -SMTPServer smtp.domain.com -To [email protected] -From [email protected] -Subject "This is a test email" -Body ...
-
Here is instruction how to make blinking text in rainmeter: 1.right click and select " Edit skin " 2.add following code to temp...
-
Error:The element 'Schedule' has invalid child element 'RecurrenceRule'. List of possible elements expected: 'Occurring&...
-
If you use Visual Studio to open a Web project that was developed for the .NET Framework 2.0, the .NET Framework 3.0, or the .NET Framework...
No comments:
Post a Comment