在wordpress博客上发表评论
我在做一个项目,在这个项目中,我必须通过wordpress博客发表评论,其中应该包含文本框中输入的文本用户。我一直在尝试用户在wordpress博客上发表评论,wordpress,post,c#-4.0,httpwebrequest,Wordpress,Post,C# 4.0,Httpwebrequest,我在做一个项目,在这个项目中,我必须通过wordpress博客发表评论,其中应该包含文本框中输入的文本用户。我一直在尝试用户HttpWebRequest,但失败并返回404 not found。连链接都没有断。这是我的代码 出于测试目的,我已在string post string post = "author=" + HttpUtility.UrlEncode("afnan") + "&email=" + HttpUtility.UrlEncode("ifi@ifi.com") + "
HttpWebRequest
,但失败并返回404 not found。连链接都没有断。这是我的代码
出于测试目的,我已在string post
string post = "author=" + HttpUtility.UrlEncode("afnan") + "&email=" + HttpUtility.UrlEncode("ifi@ifi.com") + "&url=" + HttpUtility.UrlEncode("abcd.com") +
"&comment=" + HttpUtility.UrlEncode("no comments");
HttpWebRequest wrWebRequest = WebRequest.Create("http://testing.autoprofitbot.com/blogtest/2011/05/13/call-3-computer-repair-services-put-to-test-4/wp-comments-post.php?") as HttpWebRequest;
wrWebRequest.Method = "POST";
wrWebRequest.ContentLength = post.Length;
wrWebRequest.ContentType = "application/x-www-form-urlencoded";
wrWebRequest.CookieContainer = new CookieContainer();
//// Post to the login form.
StreamWriter swRequestWriter = new
StreamWriter(wrWebRequest.GetRequestStream());
swRequestWriter.Write(post);
swRequestWriter.Close();
// Get the response.
HttpWebResponse hwrWebResponse =
(HttpWebResponse)wrWebRequest.GetResponse();
// Have some cookies.
CookieCollection ccCookies = hwrWebResponse.Cookies;
// Read the response
StreamReader srResponseReader = new
StreamReader(hwrWebResponse.GetResponseStream());
string strResponseData = srResponseReader.ReadToEnd();
srResponseReader.Close();
webBrowser1.DocumentText = strResponseData;
您的代码有3个问题:
WebRequest.Create
不正确livehttpheaders
或httpfox
获取正确的头格式李>
你能举一个例子来演示简单的表单发布感谢吗