hi this code is running fine Facebook Login
protected void Page_Load(object sender, EventArgs e)
{
//string strBuffer = "email=" + username + "&pass=" + Password + "&login=Login";
string strBuffer = "email=xxxxxxxxxxx&pass=xxxxxxxxxxxxx;login=Login";
start\_post(strBuffer);
}
public void start\_post(string strBuffer)
{
//Our postvars
byte\[\] buffer = System.Text.Encoding.ASCII.GetBytes(strBuffer);
//Initialisation
HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create("https://login.facebook.com/login.php?m&next=http%3A%2F%2Fm.facebook.com%2Fhome.php");
//Our method is post, otherwise the buffer (postvars) would be useless
WebReq.Method = "POST";
//We use form contentType, for the postvars.
WebReq.ContentType = "application/x-www-form-urlencoded";
//The length of the buffer (postvars) is used as contentlength.
WebReq.ContentLength = buffer.Length;
//We open a stream for writing the postvars
WebReq.Referer = "http://www.facebook.com/index.php?";
Stream PostData = WebReq.GetRequestStream();
//Now we write, and afterwards, we close. Closing is always important!
PostData.Write(buffer, 0, buffer.Length);
PostData.Close();
//Get the response handle, we have no true response yet!
// HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();
// //Let's show some information about the response
//WebResp.StatusCode;
//WebResp.Server;
//Now, we read the response (the string), and output it.
using (HttpWebResponse response = (HttpWebResponse)WebReq.GetResponse())
{
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
Response.Write(reader.ReadToEnd());
}
}
}
modified on Monday, November 2, 2009 7:32 AM