duanliao6789 2015-06-16 09:11
浏览 166
已采纳

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

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

how i can get the authintication from the user without changing the url "inside the iframe" ?

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;
}
  • 写回答

1条回答 默认 最新

  • drpp5680 2015-07-09 12:50
    关注

    create a facebook tab application not web application and use JS SDK

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?