using System;
using System.IO;
using System.Net;
using System.Text;
using System.Web;
class PostData {
static void Main() {
StreamWriter sw = null;
string uriString = "http://***.***.***.**/write_ok.php";
string name = "tester";
string email = "oracler@oraclejavanew.kr";
string subject = "방가와요...";
string password = "1111";
string memo = "사이트 오픈을 축하 합니다.";
string id = "guest";
string postData = "id=" + HttpUtility.UrlEncode(id) + "&" +
"name=" + HttpUtility.UrlEncode(name) + "&" +
"email=" + HttpUtility.UrlEncode(email) + "&" +
"subject" + HttpUtility.UrlEncode(subject) + "&" +
"password=" + HttpUtility.UrlEncode(password) + "&" +
"memo" + HttpUtility.UrlEncode(memo);
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(uriString);
req.Method = "POST";
req.ContentLength = postData.Length;
req.ContentType = "application/x-www-form-urlencoded";
sw = new StreamWriter(req.GetRequestStream());
//데이터를 인코딩
byte[] sendBuffer = Encoding.Default.GetBytes(postData);
//데이터를 올리자.
sw.Write(postData, 0, postData.Length );
//sw.Write(postData);
sw.Close();
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
StreamReader srData = new StreamReader(res.GetResponseStream());
//결과 스트림을 얻는다.
string outHtml = srData.ReadToEnd();
Console.WriteLine(outHtml);
res.Close();
srData.Close();
}
}
댓글 없음:
댓글 쓰기