我有一个网站,我想在其中实现 facebook 登录设施。我浏览了 facebook 开发人员页面,但它们有点模糊,无法完全理解。
我的网站是一个 php-mysql 应用程序,我已经在我的网站上有一个新用户的注册流程,但我希望用户可以选择使用他们的 facebook ID 登录,而且,一旦他们登录,我想存储他们的ID 在我的 mysql 数据库中,以便下次识别它们。
我在 SO 中经历了类似的主题,但无法破解它。如果有人可以将我链接到一个分步清晰的指南,以便在我的网站上实现这一点。
我有一个网站,我想在其中实现 facebook 登录设施。我浏览了 facebook 开发人员页面,但它们有点模糊,无法完全理解。
我的网站是一个 php-mysql 应用程序,我已经在我的网站上有一个新用户的注册流程,但我希望用户可以选择使用他们的 facebook ID 登录,而且,一旦他们登录,我想存储他们的ID 在我的 mysql 数据库中,以便下次识别它们。
我在 SO 中经历了类似的主题,但无法破解它。如果有人可以将我链接到一个分步清晰的指南,以便在我的网站上实现这一点。
刚刚对此进行了快速的 Google 搜索,并找到了以下博客文章:链接。似乎涵盖了在 php.ini 中设置 FB 登录。
该帖子说,当您调用$facebook->require_login();它时,会提示用户使用 FB 登录,然后在成功登录后,返回一个 FB id,这样您就可以编写类似$fb_id = $facebook->require_login();然后存储$fb_id.
这是完整的 hello world 示例 - 最好阅读博客文章以获得更完整的教程:
<?php
/* include the PHP Facebook Client Library to help
with the API calls and make life easy */
require_once('facebook/client/facebook.php');
/* initialize the facebook API with your application API Key
and Secret */
$facebook = new Facebook(YOUR_API_KEY,YOUR_SECRET_CODE);
/* require the user to be logged into Facebook before
using the application. If they are not logged in they
will first be directed to a Facebook login page and then
back to the application's page. require_login() returns
the user's unique ID which we will store in fb_user */
$fb_user = $facebook->require_login();
/* now we will say:
Hello USER_NAME! Welcome to my first application! */
?>
Hello <fb:name uid='<?php echo $fb_user; ?>' useyou='false' possessive='true' />! Welcome to my first application!
<?php
/* We'll also echo some information that will
help us see what's going on with the Facebook API: */
echo "<pre>Debug:" . print_r($facebook,true) . "</pre>";
?>