1

我有这个代码:

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 + "; ";
            }
        }
    }

但是站点源中有一个安全令牌,但我无法获取此令牌。帮我!

4

1 回答 1

1

我不知道如何在 vBulletin 论坛中创建新主题,但我认为如果您使用watin自动化库会更容易

于 2011-04-02T18:49:24.833 回答