C# - vBulletin new thread

自闭症网瘾萝莉.ら 提交于 2020-01-15 09:09:04

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!