授权后的Facebook应用程序的iframe重定向至Facebook页面标签 [英] Facebook iframe application after authorization redirect to facebook page tab
问题描述
我在Facebook页面授权之后重定向用户返回到应用程序标签的问题。我一直在独立的应用程序画布页面中结束。
编辑:
它本来是在标签的应用
FB了页面中。我想要做的
授权然后重定向
用户返回到页面标签。但是,当你做
这种标签看起来就像之前
它似乎像用户一个错误
因为他从授权来了,
选项卡中的应用程序看起来是一样的。他有
点击它来获得某种
响应或消息。
块引用>有没有可以下载任何例子或者某种一步一步的教程。这里是我的code:
//创建我们的应用实例。
$ Facebook的=新的Facebook(阵列(
APPID=> $运行fbconfig ['的appid'],
'秘密'=> $运行fbconfig ['秘密'],
'饼干'=>真正,
));// Facebook验证的一部分
$会议= $ facebook->的getSession();
$ loginUrl = $ facebook-> getLoginUrl(
阵列(
'画布'=> 1,
fbconnect'=> 0,
)
);$ UID = NULL; // Facebook的用户ID
$ fbme = NULL;如果(!$会话){
回声<脚本类型=文/ JavaScript的'> top.location.href ='$ loginUrl';< / SCRIPT>中;
出口;
}
其他{
尝试{
$ UID = $ facebook->的getUser();
$ fbme = $ facebook-> API('/我的领域[] = ID&放大器;场[] =姓氏和放大器;场[] = FIRST_NAME');
}
赶上(FacebookApiException $ E){
回声<脚本类型=文/ JavaScript的'> top.location.href ='$ loginUrl';< / SCRIPT>中;
出口;
}
}
解决方案没关系,我的页面选项卡中使用Ajax进行授权。这种方法也被有问题Facebook扇页标签和用户ID 」:
< DIV ID =介绍>
&下;一个的onclick =load_iframe();>&下; IMG SRC =&下; PHP的回声$运行fbconfig ['的baseUrl'],'intro.jpg'> />&下; / A>
< / DIV>
< DIV ID =FB-根>< / DIV><脚本类型=文/ JavaScript的字符集=utf-8> 功能load_iframe()
{
VAR介绍=的document.getElementById('前奏');
VAR根=的document.getElementById('FB-根'); VAR阿贾克斯=新的Ajax();
ajax.responseType = Ajax.FBML;
ajax.onerror =功能(错误)
{
新的对话框()showMessage(警报,所需的授权。,关闭);
}; ajax.ondone =功能(数据)
{
intro.setStyle('显示器','无');
root.setInnerFBML(数据);
}
ajax.requireLogin = TRUE;
ajax.post(&下; PHP的回声$运行fbconfig ['的baseUrl']≥?iframe.php);
}
< / SCRIPT>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.
Edit: 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; } }
解决方案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屋!