Thread: unable to login to facebook

  1. #1
    Registered User
    Join Date
    Jan 2009

    unable to login to facebook

    Hello Everyone

    My first post here!

    I've been struggeling with facebook the whole evening. I'm unable to login with it. It just redirects me to the front site, not replying wrong password or anything.

    Here's the code:
                string strUserName = ";// Properties.Settings.Default.facebookemail;
                string strPassword = "password";// Properties.Settings.Default.facebookpassword;
                // Get startpage and login
                string strPostData = String.Format("email={0}&pass={1}&login=Login", strUserName, strPassword);
                request = WebRequest.Create("") as HttpWebRequest;
                request.Method = "POST";
                request.ContentLength = strPostData.Length;
                request.ContentType = "application/x-www-form-urlencoded";
                request.AllowAutoRedirect = true;
                request.CookieContainer = new CookieContainer();
                request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20070309 Firefox/";
                ASCIIEncoding encoding = new ASCIIEncoding();
                byte[] loginDataBytes = encoding.GetBytes(strPostData);
                request.ContentLength = loginDataBytes.Length;
                Stream stream = request.GetRequestStream();
                stream.Write(loginDataBytes, 0, loginDataBytes.Length);
                HttpWebResponse webResp = (HttpWebResponse)request.GetResponse();
                Stream datastream = webResp.GetResponseStream();
                StreamReader reader = new StreamReader(datastream);
                myFile = File.CreateText("C:\\t.txt");
                foreach (Cookie cook in webResp.Cookies)
                    MessageBox.Show(cook.Name+" "+cook.Value);
    Anyone have an idea why?
    I've made som wireshark traces and it seems that after login is done it checks the session:

    151 11.906270 HTTP GET /checkcookie.php?r8476606e=&next=http%3A%2F%2Fwww.f 85 HTTP/1.1

    and the cookie sent is:
    Cookie: datr=1232160427-4e8b9f0fd2e204bc689bf42bf9660d84400e8024a94ed3d965 381; made_write_conn=1232160427; cur_max_lag=20; aLr\r\n

    Thereafter a 301 to then is received.

    Any help would be appreciated!

    Best regards,

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    The behavior from facebook seems right. The URL you are opening processes the login request and then redirects the user to the main page.

    What I would do is to get Fiddler and look at what your browser is sending and receiving so that you know what your program should be receiving.

    BTW it is generally a bad idea to post cookie data. I don't know how well facebook protects against cookie stealing.

  3. #3
    Registered User
    Join Date
    Jan 2009

    Thumbs up

    Hello Thantos!

    Thank's alot for your reply!

    I could not find any differences using Fiddler, i'm afraid. But after changin the connection URL to just it got returned that there was no cookies activated.

    Strange, I define the cookies before request is sent. However, with a new cookiecontainer each time. No doubt that it didn't work!

    Defining the cookiecontainer on startup solved the problem! Guess that i'm not that sharp (trying to be funny) with c# yet..

    Thank you for your help!

    Best regards,

  4. #4
    Registered User
    Join Date
    Jun 2009
    hi all!

    I'm a blonde!
    I can't understand your manipulations with C# code
    If it's not complicated write a complite code))))

  5. #5
    Registered User
    Join Date
    Mar 2010
    I turned over to use facebook mobile.. and browse that

    Working perfectly ^^

    but you inspired me thanks !

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Login
    By brietje698 in forum C++ Programming
    Replies: 3
    Last Post: 10-07-2007, 09:51 AM
  2. Having problems with a login script...
    By Junior89 in forum C++ Programming
    Replies: 6
    Last Post: 01-06-2006, 12:05 PM
  3. Login
    By cgod in forum Windows Programming
    Replies: 3
    Last Post: 02-18-2005, 04:07 PM
  4. login script - URGENT!!!
    By linzeeuk in forum C Programming
    Replies: 5
    Last Post: 05-05-2003, 02:26 PM
  5. Replies: 7
    Last Post: 07-19-2002, 11:49 AM