Hey,
I'm trying to create a program that lets you manage your own wordpress blog in multiple ways and shows you statistical data too and one of the functions that I was thinking about implementing is a function that of actually posts a comment on the blog but I'm having problems.
Here's the code that I'm using:
static void Main(string[] args)
{
byte[] buffer = Encoding.ASCII.GetBytes("author=plato&email=platom82@hotmail.com&url=&comment=Please+delete+this&submit=Submit+Comment&comment_post_ID=");
HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create("http://www.therunescapeblog.com/2010/03/analysis-of-rare-prices/wp-comments-post.php?");
WebReq.Method = "POST";
WebReq.KeepAlive = true;
WebReq.ContentType = "application/x-www-form-urlencoded";
WebReq.ContentLength = buffer.Length;
Stream PostData = WebReq.GetRequestStream();
PostData.Write(buffer, 0, buffer.Length);
PostData.Close();
HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();
Console.WriteLine(WebResp.StatusCode);
Console.WriteLine(WebResp.Server);
Stream Answer = WebResp.GetResponseStream();
StreamReader _Answer = new StreamReader(Answer);
Console.WriteLine(_Answer.ReadToEnd());
Console.ReadLine();
}
As you can see from the headers I'm trying to post a comment on this page: www.therunescapeblog.com/2010/03/analysis-of-rare-prices/
By the author "plato" whose email is "platom82@hotmail.com" who wants to say "Please delete this", however I'm encountering a few problems.
I doubt that the headers are incorrect as I've obtained them from an http sniffer. The uri is probably incorrect however I've tried changing the uri and headers for thousands of combinations but never actually managed to post a comment via HttpWebRequest.
I've never been able to understand HttpWebRequest/HttpWebResponses anyway so I've decided to seek some professional help.
Does anyone know what I'm doing wrong?
Thanks a lot!