I trying to write a program (C#) that can login and create new thread into VBulletin forums. I tried 2 way:
1) Use HttpWebRequest : Login is done. However creating new thread is fail. This is posting code:
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();
}
When a execute the code above, no any theard has been created !
2) Use WebBrowser control:
webBrowser1.Document.GetElementById("navbar_username").InnerText = "admin";
webBrowser1.Document.GetElementById("navbar_password").InnerText = "123";
But I cant not submit because the has no name/id, and Login button is same ! Please tell me how to submit a form without form name/id and button name/id ?
Thanks !
Best regard,