简体   繁体   English

Facebook应用在Facebook页面内获取身份验证

[英]facebook app get authentication inside a facebook page

I have a facebook page I have built an application to be in the page tab the application works fine with the original url it get the login from the facebook and return to the url 我有一个Facebook页面,我已经在页面选项卡中构建了一个应用程序,该应用程序可以很好地与原始网址一起使用,它可以从Facebook获得登录信息并返回该网址

how i can get the authintication from the user without changing the url "inside the iframe" ? 我如何在不更改“ iframe内” URL的情况下从用户获得身份验证?

require_once("facebook.php");
$facebook = new Facebook(array(
        'appId' => 'App_id',
        'secret' => 'Secret'));
$current_user = $facebook->getUser();

$params = array('scope' =>'email,user_likes,user_friends');
if ($current_user) { 
    try {
            $expiration = time() + 172800; 
            $cookie_value = $current_user . '|' . $expiration;
            setcookie('fbid', $cookie_value, $expiration , "/");
            echo '<script type="text/javascript">
            window.location = "like.php";
            </script>';
    } catch (FacebookApiException $e) {
        $login_url = $facebook->getLoginUrl($params);
        echo '<script type="text/javascript">
        window.location = "' . $login_url . '";
        </script>';
        exit;
        error_log($e->getType());
        error_log($e->getMessage());
    }
} else {
    $login_url = $facebook->getLoginUrl($params);
    echo '<script type="text/javascript">
        window.location = "'.$login_url.'";
        </script>';
    exit;
}

创建一个Facebook选项卡应用程序而不是Web应用程序并使用JS SDK

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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