Hey guys,
I've recently been developing a C# application for myself and a friend of mine and I've basically managed to code everything except one feature that basically gets the amount of credits that you have on your account from a site called getref.com.
To do this I need to either login the account via a Login URL by means of the WebClient Object in the .Net Framework which would look something like:
I can then simply parse the string strRes to find the amount of credits.Code:WebClient myClient = new WebClient(); string strRes = myClient.DownloadString("http://ww.getref.com/processlogin.asp?&txtUsername=<username>&txtPassword=<password>&login=Logon");
I can also try to login via an HttpWebRequest:
Just like the other example I can then simply parse the string strRes to find the amount of credits as well.Code:string User = "******"; string Pass = "******"; string url = "http://ww.getref.com/processlogin.asp"; string pdata = "&txtusername=" + User + "&txtpassword=" + Pass + "&login=Logon"; string strRes = SendWebRequest(url, pdata, 8, ""); private static string SendWebRequest(string Url, string PData, int Interval, string Referer) { HttpWebRequest req = (HttpWebRequest)WebRequest.Create(Url); if (PData != "") { req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; byte[] arrbytes = Encoding.ASCII.GetBytes(PData); req.ContentLength = arrbytes.Length; Stream reqStream = req.GetRequestStream(); reqStream.Write(arrbytes, 0, arrbytes.Length); reqStream.Close(); } if (Referer != "") { req.Referer = Referer; } req.Timeout = Interval * 0x3e8; HttpWebResponse httpresponse = (HttpWebResponse)req.GetResponse(); StreamReader _streamreader = new StreamReader(httpresponse.GetResponseStream()); return _streamreader.ReadToEnd().ToString(); }
My problem is that of finding the correct login Url to login or that of creating the right HttpWebRequest for logging in. :/
Does anyone know what I'm doing wrong?
Are my HTTP Headers incorrect?
Am I crafting my query properly?
Sorry if I'm doing a lot of stupid mistakes. I'm very inexperienced when it comes to web dev thats why I decided to ask the pros xD.
Thanks a lot.
Regards,
CSharpGuy.




Reply With Quote