gpt4 book ai didi

php - 授权后的 Facebook iframe 应用程序重定向到 Facebook 页面选项卡

转载 作者:行者123 更新时间:2023-12-04 06:41:54 27 4
gpt4 key购买 nike

我在授权后将用户重定向回 facebook 页面中的应用程序选项卡时遇到问题。我总是以独立的应用程序 Canvas 页面结束。

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.



是否有任何可以下载的示例或某种分步教程。这是我的代码:
// 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;
}
}

最佳答案

没关系,我已经在 Page 选项卡中使用 Ajax 完成了授权。此方法也在问题“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>

关于php - 授权后的 Facebook iframe 应用程序重定向到 Facebook 页面选项卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4143045/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com