Facebook的iframe应用程序授权后重定向到Facebook页面选项卡 [英] Facebook iframe application after authorization redirect to facebook page tab

查看:165
本文介绍了Facebook的iframe应用程序授权后重定向到Facebook页面选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有权利将用户重定向到Facebook页面上的应用程序选项卡。我总是在独立的应用程序画布页面。

I have problems with redirecting user after authorization back to the app tab in facebook page. I always end up in standalone application canvas page.


编辑:
这是为了一个Fb页面中的
的应用程序。我想要执行
授权,然后将
用户重定向到页面选项卡。但是当你做
这个标签看起来就像以前的
,似乎用户喜欢一个错误
,因为他来自授权和
应用程序在选项卡看起来是一样的。他有
点击它来获得某种
的回复或消息。

It was meant to be an app in tab within a Fb page. I wanted to do the authorization and then to redirect user back to page tab. But when you do this the tab looks just like before and it seems to user like an error because he came from authorization and the app in tab looks the same. He has to click on it to get some kind of response or message.

有没有例子可以下载或某种分步教程。这是我的代码:

Is there any example that can be downloaded or some kind of step-by-step tutorial. Here is my code:

// Create our Application instance.
$facebook = new Facebook(array(
  'appId'  => $fbconfig['appid'],
  'secret' => $fbconfig['secret'],
  'cookie' => true,
));

//Facebook Authentication part
$session = $facebook->getSession();
$loginUrl = $facebook->getLoginUrl(
        array(
        'canvas'    => 1,
        'fbconnect' => 0,
        )
);

$uid = null; //facebook user id
$fbme = null;

if (!$session) {
    echo "<script type='text/javascript'>top.location.href = '$loginUrl';</script>";
    exit;
}
else {
    try {
        $uid  = $facebook->getUser();
        $fbme = $facebook->api('/me?fields[]=id&fields[]=last_name&fields[]=first_name');
    }
    catch (FacebookApiException $e) {
        echo "<script type='text/javascript'>top.location.href = '$loginUrl';</script>";
        exit;
    }
}


推荐答案

我已经在页面选项卡中完成了使用Ajax的授权。此方法也在 Facebook粉丝专页选项卡和用户id。

Never mind I've done authorization using Ajax within Page tab. This method is also described in question "Facebook fan page tab and user id.":

<div id="intro">
    <a onclick="load_iframe();"><img src="<?php echo $fbconfig['baseUrl'], 'intro.jpg' ?>" /></a>
</div>
<div id="fb-root"></div>

<script type="text/javascript" charset="utf-8">

    function load_iframe()
    {
        var intro = document.getElementById('intro');
        var root = document.getElementById('fb-root');

        var ajax = new Ajax();
        ajax.responseType = Ajax.FBML;
        ajax.onerror = function(error)
        {
            new Dialog().showMessage("Alert", "Required authorization.","Close");
        };

        ajax.ondone = function(data)
        {
            intro.setStyle('display', 'none');
            root.setInnerFBML(data);
        }
        ajax.requireLogin = true;
        ajax.post("<?php echo $fbconfig['baseUrl'] ?>iframe.php");
    }
</script>

这篇关于Facebook的iframe应用程序授权后重定向到Facebook页面选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆