簡體   English   中英

如何在vBulletin論壇上使用C#創建新線程?

[英]How to create new threads using c# on vBulletin forum?

我有以下代碼:

public void WriteNewTopic(string subject, string message)
    {
        _webRequest = (HttpWebRequest)WebRequest.Create(this.Url + "newthread.php?do=newthread&f=" + AppsId);
        _webRequest.Headers.Add("Cookie", this.Cookie);
        _webRequest.UserAgent = "Mozilla/5.0 (Windows NT 5.1; rv:2.0) Gecko/20100101 Firefox/4.0";
        _webRequest.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
        _webRequest.ContentType = "application/x-www-form-urlencoded";
        _webRequest.Referer = this.Url + "viewforum.php?f=" + this.AppsId;
        _webRequest.Headers.Add("Accept-Charset", "ISO-8859-2,utf-8;q=0.7,*;q=0.7");
        _webRequest.Headers.Add("Accept-Encoding", "gzip, deflate");
        _webRequest.Headers.Add("Accept-Language", "pl,en-us;q=0.7,en;q=0.3");
        _webRequest.Method = "POST";
        _webRequest.CookieContainer = _cookieContainer;
        _webRequest.AllowAutoRedirect = false;

        string values =
            "do=postthread&f=" + AppsId +
            "&securitytoken=1301767251-1a5636806411d07afb5cfde72c4f0978a1cf4415" + 
            "&wysiwyg=0&subject=" + subject +
            "&message=" + message;

        _webRequest.ContentLength = values.Length;

        byte[] buffer = new byte[256];
        ASCIIEncoding ascii = new ASCIIEncoding();
        buffer = ascii.GetBytes(values);
        using (Stream stream = _webRequest.GetRequestStream())
        {
            stream.Write(buffer, 0, buffer.Length);
        }

        HttpWebResponse c;
        try
        {
            c = (HttpWebResponse)_webRequest.GetResponse();
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
            return;
        }

        if (c.Cookies.Count != 0)
        {
            this.Cookie = string.Empty;
            foreach (Cookie cook in c.Cookies)
            {
                cook.HttpOnly = true;
                Cookie = Cookie + cook + "; ";
            }
        }
    }

但是站點源中有一個安全令牌,但是我無法獲得此令牌。 幫我!

我不知道如何在vBulletin論壇中創建新線程,但是我認為如果使用watin自動化庫,它將更加容易

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM