Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. facebook login.

facebook login.

Scheduled Pinned Locked Moved C#
phpdatabasecomsysadminagentic-ai
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    udikantz
    wrote on last edited by
    #1

    hey im trying to make an app that will log in to facebook , im using the following method to establish connection and post my credentials: public static void start_post(string strPage, string strBuffer) { //Our postvars byte[] buffer = Encoding.ASCII.GetBytes(strBuffer); //Initialisation HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(strPage); //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 Console.WriteLine(WebResp.StatusCode); Console.WriteLine(WebResp.Server); //Now, we read the response (the string), and output it. Stream Answer = WebResp.GetResponseStream(); StreamReader _Answer = new StreamReader(Answer); reply = _Answer.ReadToEnd(); Console.WriteLine(reply); } i get the following respond from facebook: "sorry, we're not cool enough to support your browser. please keep it real with the following browsers: ...." any idea how to work around this facebook check , as im sending same data as my IE agent i dont know what else will work , asking for your expert help. thank you.

    Net

    L B U 3 Replies Last reply
    0
    • U udikantz

      hey im trying to make an app that will log in to facebook , im using the following method to establish connection and post my credentials: public static void start_post(string strPage, string strBuffer) { //Our postvars byte[] buffer = Encoding.ASCII.GetBytes(strBuffer); //Initialisation HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(strPage); //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 Console.WriteLine(WebResp.StatusCode); Console.WriteLine(WebResp.Server); //Now, we read the response (the string), and output it. Stream Answer = WebResp.GetResponseStream(); StreamReader _Answer = new StreamReader(Answer); reply = _Answer.ReadToEnd(); Console.WriteLine(reply); } i get the following respond from facebook: "sorry, we're not cool enough to support your browser. please keep it real with the following browsers: ...." any idea how to work around this facebook check , as im sending same data as my IE agent i dont know what else will work , asking for your expert help. thank you.

      Net

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      udikantz wrote:

      as im sending same data as my IE agent i dont know what else will work

      And just where do you set that? I dont see it anywhere in your code. Try again.

      xacc.ide - now with TabsToSpaces support
      IronScheme - 1.0 alpha 4a out now (29 May 2008)

      U 1 Reply Last reply
      0
      • L leppie

        udikantz wrote:

        as im sending same data as my IE agent i dont know what else will work

        And just where do you set that? I dont see it anywhere in your code. Try again.

        xacc.ide - now with TabsToSpaces support
        IronScheme - 1.0 alpha 4a out now (29 May 2008)

        U Offline
        U Offline
        udikantz
        wrote on last edited by
        #3

        i set that in a the main class of the project these are the parameters that i pass to the method , i chenged the email and password to something fake be it looks something like that: start_post("https://login.facebook.com/login.php", "challenge=e7d654f99268a01kl94007be0e399755&md5pass=1&noerror=1&email=someemail@gmail.com&pass=coolpassword&charset_test=%E2%82%AC%2C%C2%B4%2C%E2%82%AC%2C%C2%B4%2C%E6%B0%B4%2C%D0%94%2C%D0%84");

        Net

        1 Reply Last reply
        0
        • U udikantz

          hey im trying to make an app that will log in to facebook , im using the following method to establish connection and post my credentials: public static void start_post(string strPage, string strBuffer) { //Our postvars byte[] buffer = Encoding.ASCII.GetBytes(strBuffer); //Initialisation HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(strPage); //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 Console.WriteLine(WebResp.StatusCode); Console.WriteLine(WebResp.Server); //Now, we read the response (the string), and output it. Stream Answer = WebResp.GetResponseStream(); StreamReader _Answer = new StreamReader(Answer); reply = _Answer.ReadToEnd(); Console.WriteLine(reply); } i get the following respond from facebook: "sorry, we're not cool enough to support your browser. please keep it real with the following browsers: ...." any idea how to work around this facebook check , as im sending same data as my IE agent i dont know what else will work , asking for your expert help. thank you.

          Net

          B Offline
          B Offline
          Brandon Toner
          wrote on last edited by
          #4

          I had the same problem and i used the line

          WebReq.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.7) Gecko/2009021910 Firefox/3.0.7 (.NET CLR 3.5.30729)";

          it makes the server think that its running FireFox

          1 Reply Last reply
          0
          • U udikantz

            hey im trying to make an app that will log in to facebook , im using the following method to establish connection and post my credentials: public static void start_post(string strPage, string strBuffer) { //Our postvars byte[] buffer = Encoding.ASCII.GetBytes(strBuffer); //Initialisation HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(strPage); //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 Console.WriteLine(WebResp.StatusCode); Console.WriteLine(WebResp.Server); //Now, we read the response (the string), and output it. Stream Answer = WebResp.GetResponseStream(); StreamReader _Answer = new StreamReader(Answer); reply = _Answer.ReadToEnd(); Console.WriteLine(reply); } i get the following respond from facebook: "sorry, we're not cool enough to support your browser. please keep it real with the following browsers: ...." any idea how to work around this facebook check , as im sending same data as my IE agent i dont know what else will work , asking for your expert help. thank you.

            Net

            U Offline
            U Offline
            User 4105131
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups