简体   繁体   中英

How to provide a facebook login with facebook-php-sdk?

I try to provide a login with the facebook-php-sdk. But, when I click on the login link facebook throw me this message: "an error occurred. Please try again later"

<?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>

I try to manage with the facebook-js-sdk but I have got the same error.

Thanks in advance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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