问题
i tried this:
public static void CreateNewThread(string url,string fId, string title, string message, string tag)
{
url += "newthread.php?do=postthread";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
//string result = "";
string values = "subject=" + title
+ "&message=" + message
+ "&tag=" + tag
+ "&do=postthread"
+ "&f=" + fId
+ "&s="
+ ""
;
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = values.Length;
ServicePointManager.Expect100Continue = false; // prevents 417 error
using (StreamWriter writer = new StreamWriter(req.GetRequestStream(), Encoding.UTF8))
{
writer.Write(values);
}
HttpWebResponse c = (HttpWebResponse)req.GetResponse();
}
But this is doesnt work!
回答1:
Try encoding the subject and message paramaters:
HttpUtility.UrlEncode(
string values = "subject=" + HttpUtility.UrlEncode(title)
+ "&message=" + HttpUtility.UrlEncode(message)
+ "&tag=" + HttpUtility.UrlEncode(tag)
+ "&do=postthread"
+ "&f=" + fId
+ "&s="
+ ""
;
来源:https://stackoverflow.com/questions/4571381/c-sharp-vbulletin-new-thread