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

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

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?