Facebook iframe 应用程序授权后重定向到 Facebook 页面选项卡
我在授权后将用户重定向回 Facebook 页面中的应用程序选项卡时遇到问题。我总是最终进入独立的应用程序画布页面。
编辑: 它本来是一个选项卡中的应用程序 在 Facebook 页面内。我想做 授权然后重定向 用户返回页面选项卡。但当你这样做时 这个选项卡看起来就像以前一样 对用户来说似乎是一个错误 因为他来自授权并且 选项卡中的应用程序看起来相同。他有 单击它以获得某种 回复或消息。
是否有任何可以下载的示例或某种分步教程。这是我的代码:
// 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;
}
}
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;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没关系,我已经在“页面”选项卡中使用 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.":