简体   繁体   中英

how to login to facebook with c# without the facebook page

I am pretty new at programming. I saw many examples on how to c# login to facebook, all of them are using the facebook login page to login. my question is how do I pass the username and the password form my own text box I create and my own login button. is it possible ?

Pretty sure you can't do this.

The only way to authenticate with Facebook is via a Facebook login page.

If Facebook allowed login via 3rd party forms, there would be nothing to stop malicious sites from collecting Facebook login details.

It really depends on what you are trying to accomplish. There are some integration API's for Facebook if you have a site that you want to integrate with Facebook.

The only way I've found to login directly from a desktop app, is by using a WebBrowser class, requesting the facebook login page, then populating the username/password fields programmatically: webBrowser1.Document.GetElementById("textName").SetAttribute("value") = "ddddd" ;

The result of the login will produce several cookies that identify the session, and you can transfer those into a HttpWebRequest so that you requests will be seen as logged in.

Like Rik said, this is a very bad practice because you'd have to collect user details through your own form, (although you could always display the WebBrowser window directly to the user, you are still asking them to do something very risky because the application hosting the WebBrowser class can intercept the login information).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM