php 如何使用 Facebook 在我的网站上进行用户登录?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4169491/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 12:11:43  来源:igfitidea点击:

how to use facebook for user login on my website?

phphtmlfacebook

提问by dynamic

i am wondering how facebook works for logging in user on our websites.

我想知道 facebook 如何在我们的网站上登录用户。

I mean a user needs to be registered to my website for posting a comment, how can I check trough my php code if it's a logged user?

我的意思是用户需要注册到我的网站才能发表评论,如果它是登录用户,我如何通过我的 php 代码进行检查?

I heard you can only check if it's a logged user with javascript

我听说您只能使用 javascript 检查它是否是登录用户

Thanks for any explanation

感谢您的任何解释

采纳答案by Halil ?zgür

You can use the Facebook PHP SDKto check if a user is logged in with Facebook, and optionally get information about her/him. That way you can let your users complete their registrations or use your website with some restrictions.

您可以使用Facebook PHP SDK来检查用户是否使用 Facebook 登录,并可选择获取有关她/他的信息。这样您就可以让您的用户完成注册或在有一些限制的情况下使用您的网站。

But you need to register a Facebook Application first, as that application will be shown when asking the user about for permissions you require.

但是您需要先注册一个 Facebook 应用程序,因为在询问用户您需要的权限时会显示该应用程序。

回答by Byron Whitlock

You don't need JavaScript to do this, but Facebook makes it pretty simple to use thier JavaScript lib. You dohave access to whether or not the user is logged in in php using this method.

您不需要 JavaScript 来执行此操作,但 Facebook 使使用其 JavaScript 库变得非常简单。您确实可以使用此方法访问用户是否已登录 php。

Take a look at the single signon section of the developers API.

查看开发人员 API的单点登录部分。

回答by Jeremy

If you are running a software package like Wordpress or phpBB you could google around to find a plugin that did it for you. Otherwise, ignore this ;)

如果您正在运行像 Wordpress 或 phpBB 这样的软件包,您可以通过谷歌搜索找到适合您的插件。否则,忽略这个;)