C# - vBulletin new thread

2019-07-29 07:29发布

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!

标签: c# vbulletin
1条回答
戒情不戒烟
2楼-- · 2019-07-29 07:46

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="
                    + ""
                    ;
查看更多
登录 后发表回答