I managed to do a successful login into facebook using the INET control in vb6 !!!!!
I did this: Inet1.Execute "https://www.facebook.com" Then in StateChanged event, when the response is completed (State = icResponseCompleted), I pick up the cookies supplied by FB. The facebook throws the login page's HTML data. Cookie = Inet1.GetHeader("Set-Cookie") If Cookie <> "" Then Cookie = "Cookie: " & Left(Cookie, InStr(Cookie, " ") - 1) It retrieves me the 'datr' cookie which I believe is the main login cookie used by FB. Then I use this cookie with my login info: Inet1.Execute "https://login.facebook.com/login.php?login_attempt=1", "POST", "email=" & txtID & "&pass=" & txtPass & "&persistent=1", Cookie Voila! it signs in and returns the home page's HTML data. :o) Now the problem is that this is VB6 and INET is not for VB.NET. Next problem is that the cookies that I set thru INET is 'shared' by Internet Explorer. If I do a login into FB and then open www.facebook.com/home.php on IE, it automatically signs me in. I dont want that to happen, I want to keep a private session within my application. On Dec 3, 1:16 pm, Processor Devil <[email protected]> wrote: > using HTTPWebRequest you are going to use their page... :D. All you just > need is to obtain the headers, then. > I will try to look at it on weekend, I have no time to connect on internet > from home during the working days (traveling, word, traveling, sleep, etc, > etc, etc...) > > 2009/12/2 Brandon Betances <[email protected]> > > > > > Already told you why bro FB wont allow logins from anywhere else but their > > own page. Server usually times out. Think it has something to do with a > > token. > > > On Tue, Dec 1, 2009 at 11:18 AM, Faraz Azhar <[email protected]> wrote: > > >> and talk about security weakness... doing a login procedure on client > >> side! > > >> Anyway, back to the topic :P :D ... anybody got any clue why my code > >> isnt able to do a proper login? > > >> On Dec 1, 4:45 pm, Processor Devil <[email protected]> wrote: > >> > well, it would be foolish if javascripts were really needed for the > >> login... > >> > What about ppl who disable javascript in browser or their browser > >> doesn't > >> > support it? > > >> > 2009/12/1 Faraz Azhar <[email protected]> > > >> > > Hmm... i just went thru the javascripts in it's login page. Theyve got > >> > > hash codes but its only for downloading the CSS files. Its got nothing > >> > > to do with login. So scripts wont be an obstacle in doing an automated > >> > > login. > > >> > > One script creates a cookie called 'test_cookie' at runtime (ie. on > >> > > client side) which I think its only doing just to check if browser > >> > > supports the cookie ability. SO all in all, javascripts have no > >> > > interference with the login procedure. > > >> > > On Nov 30, 8:17 pm, ThanderMaX <[email protected]> wrote: > >> > > > Hm... > > >> > > > Do you have plan to automate those javascripts ? Their are lots of > >> > > > onsubmit javascript with few hashing functions (including few pre- > >> > > > seeded values).. are you planning to simulate them also ??? > > >> > > > Let me know , if you are successful . > > >> > > > On Nov 30, 2:35 pm, Faraz Azhar <[email protected]> wrote: > > >> > > > > Yes thats exactly what im trying to do. Im not using a browser. Im > >> > > > > just performing the functions a browser does in the background. > >> But > >> > > > > instead of WebRequest, im using WebClient. Its almost same thing > >> so > >> > > > > shouldnt be any difficulty. > > >> > > > > But the problem is that I am unable to login properly. I posted a > >> link > >> > > > > to my code, have a look. I cant figure out what Im missing. > > >> > > > > On Nov 30, 1:17 pm, Processor Devil <[email protected]> > >> wrote: > > >> > > > > > man, you don't even need a browser... All you need is WebRequest > >> and > >> > > > > > cookies! > > >> > > > > > 2009/11/30 Faraz Azhar <[email protected]> > > >> > > > > > > Guys why do I need APIs for that ? Im just trying to do a > >> simple > >> > > > > > > logging-in into facebook. Its a simple browser function. > > >> > > > > > > If any browser can sign into facebook, then WebClient can also > >> do > >> > > it > >> > > > > > > im sure. The question is not only facebook specific, it can be > >> for > >> > > any > >> > > > > > > website that requires logging-in thru cookies and ID/Password. > > >> > > > > > > On Nov 29, 8:24 pm, ThanderMaX <[email protected]> > >> wrote: > >> > > > > > > > To connect to facebook from code , u need to lunch their > >> login > >> > > window > >> > > > > > > > in a webcontrol and handle the proper events . > > >> > > > > > > > Take a look in the following link : > > >> > >http://wiki.developers.facebook.com/index.php/Authorization_and_Authe. > >> .. > > >> > > > > > > > Above code is written , most probably Mac OSx in mind. But > >> it's > >> > > the > >> > > > > > > > coding style that is important. > > >> > > > > > > > But most importantly , you need to have a developer specific > >> API > >> > > key , > >> > > > > > > > which will be used for tracking and house-keeping > >> (internally). > >> > > Please > >> > > > > > > > do register in the parent site and get your key. > >> > > > > > > > [Same procedure as symbion development]. > > >> > > > > > > > Good luck! > > >> > > > > > > > On Nov 28, 12:48 pm, Faraz Azhar <[email protected]> > >> wrote: > > >> > > > > > > > > Hello > > >> > > > > > > > > Im working on VB.NET <http://vb.net/> and im trying to do > >> an automated login in > >> > > > > > > > > Facebook. I've tried many ways such as HTTPWebRequest, > >> > > WebClient, > >> > > > > > > > > socket approach, WebBrowser, etc. > > >> > > > > > > > > Only the webbrowser turned out to be successful, but that > >> was > >> > > the > >> > > > > > > > > lamest way. I was entering ID and Password directly into > >> the > >> > > webpage > >> > > > > > > > > after it was loaded and then submitting the form. I just > >> want > >> > > the html > >> > > > > > > > > data so webbrowser doesnt fulfill the purpose as the > >> webbrowser > >> > > starts > >> > > > > > > > > loading flash and other scripts and images. In other words > >> im > >> > > trying > >> > > > > > > > > to do screen scraping of facebook. > > >> > > > > > > > > The hurdles in this coding is that login into the facebook > >> > > requires > >> > > > > > > > > form submitting AND handling cookies. > > >> > > > > > > > > I've made up a code using WebClient. Have a look! > >> > > > > > >http://dotnetdevelopment.pastebin.com/m285ff7cd > > >> > > > > > > > > My approach has been this way: > >> > > > > > > > > 1. First try to open thewww.facebook.com/home.php > >> > > > > > > > > 2. Obviously it wont open as we haven't logged in yet. So > >> we > >> > > will be > >> > > > > > > > > redirected to a login page. > >> > > > > > > > > 3. I extract the Cookies received thru this response. > >> > > > > > > > > 4. I extract the hidden input tags in the HTML submit > >> form. > >> > > > > > > > > 5. Finally I will build up a fresh web request and insert > >> the > >> > > cookies > >> > > > > > > > > received above along with the input tags, and of course > >> the > >> > > user ID > >> > > > > > > > > and password. > > >> > > > > > > > > Now I *should* be arriving at a plain 2 line web page > >> which > >> > > says that > >> > > > > > > > > login was successful and asks to redirect ourselves to the > >> home > >> > > page. > >> > > > > > > > > *BUT* I am not getting this page. I've tried all possible > >> ways > >> > > to > >> > > > > > > > > achieve this objective but I am failing terribly. Two > >> common > >> > > errors > >> > > > > > > > > that facebook gives is that 'web browser is not cookie > >> enabled' > >> > > or > >> > > > > > > > > 'incompatible browser'. But those issues have been > >> resolved by > >> > > me. > >> > > > > > > > > First one required proper handling of cookies, latter one > >> > > required > >> > > > > > > > > UserAgent header to be set in the request. > > >> > > > > > > > > Right now im stuck at nowhere. I try to send the request > >> but > >> > > facebook > >> > > > > > > > > throws me back to the login page without giving any error > >> > > message. > > >> > > > > > > > > Need help! > > >> > > > > > > > > PS. My code above includes another function for handling > >> > > cookies. Its > >> > > > > > > > > code is here: > >>http://dotnetdevelopment.pastebin.com/m313ec4b5
