using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;
class http
{
static void Main(string[] args)
{
var gallid = "programming";
var gallnum = "" + 404863;
HttpWebRequest client = WebRequest.Create("http://g...content-available-to-author-only...e.com/board/view/?id="+gallid+"&no=" + gallnum) as HttpWebRequest;
HttpWebResponse res = client.GetResponse() as HttpWebResponse;
var cookCode = res.GetResponseHeader("Set-Cookie");
int st = cookCode.IndexOf("ci_c=") + 5;
cookCode = cookCode.Substring(st, 32);
Console.WriteLine(cookCode);
StringBuilder PostContent = new StringBuilder();
PostContent.Append("id=" + gallid);
PostContent.Append("&no=" + gallnum);
PostContent.Append("&memo=" + "test");
PostContent.Append("&ci_t=" + cookCode);
PostContent.Append("&name=" +"dd");
PostContent.Append("&password=" + "123123");
byte[] bp = Encoding.UTF8.GetBytes(PostContent.ToString());
HttpWebRequest httpPost = HttpWebRequest.Create("http://g...content-available-to-author-only...e.com/forms/comment_submit") as HttpWebRequest;//WebRequest.Create("http://g...content-available-to-author-only...e.com/forms/comment_submit") as HttpWebRequest;
httpPost.Method = "POST";
httpPost.KeepAlive = true;
httpPost.ContentLength = bp.Length;
httpPost.Accept = "*/*";
httpPost.Headers.Add("Accept-Encoding", "gzip,deflate,sdch");
httpPost.Headers.Add("Accept-Language",
"ko-KR,ko;q=0.8,en-US;q=0.6,en;q=0.4");
httpPost.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
httpPost.Headers.Add("Origin", "http://g...content-available-to-author-only...e.com");
httpPost.Referer =
"http://g...content-available-to-author-only...e.com/board/view/?id=" + gallid + "&no=" + gallnum;
httpPost.UserAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36";
httpPost.Headers.Add("X-Requested-With", "XMLHttpRequest");
httpPost.Expect = null;
using (var stream = httpPost.GetRequestStream())
{
stream.Write(bp, 0, bp.Length);
stream.Close();
}
res = httpPost.GetResponse() as HttpWebResponse;
System.IO.StreamReader instream = new System.IO.StreamReader(res.GetResponseStream());
Console.WriteLine(instream.ReadToEnd());
}
}