0

我想知道如何登录到 Vbulletin 论坛,确认登录后,它会获取个人用户组 ID,然后在标签中显示组名。

我可以让它从cookies登录。下面的示例,但我无法弄清楚需要做什么,因此它获取用户组 ID,然后从 id 获取名称。我是否需要为它制作一个 php 文件以从中获取信息或究竟需要做什么?

    static string login(string url, string username, string password)
    {
        HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
        string cookie = "";
        string values = "vb_login_username=" + username + "&vb_login_password=" + password
                            + "securitytoken=guest&"
                            + "cookieuser=checked&"
                            + "do=login";
        req.Method = "POST";
        req.ContentType = "application/x-www-form-urlencoded";
        req.ContentLength = values.Length;
        CookieContainer a = new CookieContainer();
        req.CookieContainer = a;

        System.Net.ServicePointManager.Expect100Continue = false; // prevents 417 error

        using (StreamWriter writer = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII)) { writer.Write(values); }

        HttpWebResponse c = (HttpWebResponse)req.GetResponse();
        foreach (Cookie cook in c.Cookies) { cookie = cookie + cook.ToString() + ";"; }

        return cookie;
    }
4

0 回答 0