Facebook登录实现


Facebook login implementation

我有一个网站,我想实现facebook登录设施。我浏览了facebook的开发者页面,但他们有点模糊,无法完全理解。

我的网站是一个php-mysql应用程序,我已经在我的网站新用户的注册过程中,但我希望用户有登录与他们的facebook的ID的选项,而且,一旦他们登录,我要存储他们的ID在我的mysql数据库下次识别他们。

我已经通过了类似的主题在SO,但无法破解它。如果有人能给我一个循序渐进的指南,在我的网站上实现这个

看一看

http://developers.facebook.com/blog/post/503/

我在谷歌上快速搜索了一下,发现了下面的博客文章:链接。似乎涵盖了在php中设置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>";
?>