如何使用facebook-php-sdk提供Facebook登录?

问题描述:

我尝试使用facebook-php-sdk提供登录。但是,当我点击登录链接Facebook的把我这个消息:“一个错误发生,请稍后再试”如何使用facebook-php-sdk提供Facebook登录?

<?php 
require_once('php-sdk/src/facebook.php'); 

define('APP_ID', 'blabla'); 
define('APP_SECRET', 'blibli'); 

$facebook = new Facebook(array(
    'appId' => APP_ID, 
    'secret' => APP_SECRET, 
)); 

$params = array(
    'scope' => 'read_stream, friends_likes', 
    'redirect_uri' => 'http://127.0.0.1' 
); 

$login_url = $facebook->getLoginUrl($params); 
$user_id = $facebook->getUser(); 

?> 
<!DOCTYPE html> 
<html> 
    <head> 
     <title>info-intox.tv</title> 
     <meta charset="utf-8" /> 
    </head> 
    <body> 
    <?php if ($user_id) { ?> 
     <form action="index.php" method="post"> 
      <input type="text" name="txtPostId" /> 
      <input type="submit" value="Get the CSV file" /> 
     </form> 
    <?php } else { ?> 
     <a href="<?php echo $login_url ?>">Login</a> 
    <?php } ?> 
    </body> 
</html> 

我尝试与Facebook的JS-SDK来管理,但我得到了同样的错误。

在此先感谢。

+0

可能重复尝试这个http://*.com/questions/7231939/redirecting-to-authentication-dialog-an-error-occurred-please-try-again-late – 2012-03-26 12:55:42

+0

我发现了一个解决方案,我在“选择你的应用如何与Facebook集成”一章下启用了我的网站的Facebook登录。 感谢jalso的帮助! – gperriard 2012-03-29 09:33:55