简体   繁体   English

如何在没有facebook页面的情况下使用c#登录facebook

[英]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. 我看到很多关于如何c#登录facebook的例子,他们都使用facebook登录页面登录。 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. 使用Facebook进行身份验证的唯一方法是通过Facebook登录页面。

If Facebook allowed login via 3rd party forms, there would be nothing to stop malicious sites from collecting Facebook login details. 如果Facebook允许通过第三方表单登录,则没有什么可以阻止恶意网站收集Facebook登录详细信息。

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. 如果您有一个想要与Facebook集成的网站,那么Facebook有一些集成API。

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" ; 我发现直接从桌面应用程序登录的唯一方法是使用WebBrowser类,请求facebook登录页面,然后以编程方式填充用户名/密码字段: 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. 登录的结果将生成几个标识会话的cookie,您可以将它们转移到HttpWebRequest中,以便您的请求将被视为已登录。

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). 就像Rik所说,这是一个非常糟糕的做法,因为你必须通过自己的表单收集用户详细信息,(尽管你总是可以直接向用户显示WebBrowser窗口,但你仍然要求他们做一些非常冒险的事情,因为托管WebBrowser类的应用程序可以拦截登录信息)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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