Facebook身份验证对话框未显示在页面选项卡中 [英] Facebook auth dialog doesn't show up in page tab
问题描述
在页面标签(iframe)中查看应用程序时,不会显示Facebook身份验证对话框. 不过,从外部查看应用程序时,效果很好.
The Facebook Auth Dialog won't show up when viewing the app in a page tab (iframe). It works fine when viewing the app externaly though.
我的Facebook应用程序设置为:
My Facebook app settings are:
Site URL: http://domain.com/test
Canvas URL: http://domain.com/test/
Secure Canvas URL: https://domain.com/test/
Page Tab URL: http://domain.com/test/
Secure Page Tab URL: https://domain.com/test/
我已使用链接将应用程序添加到页面标签ny中: https://www.facebook.com/dialog/pagetab?app_id= [MY_APP_ID]& next = https://domain.com/test/
I've added the app to the page tab ny using the link: https://www.facebook.com/dialog/pagetab?app_id=[MY_APP_ID]&next=https://domain.com/test/
我正在使用PHP SDK. //domain.com/test/index.php中的代码如下:
I'm using the php sdk. And my code in //domain.com/test/index.php looks like this:
<?php
require 'facebook-php-sdk/src/facebook.php';
$facebook = new Facebook(array(
'appId' => '[MY_APP_ID]',
'secret' => '[MY_APP_SECRET]',
));
// Get User ID
$user = $facebook->getUser();
if ($user) {
$logoutUrl = $facebook->getLogoutUrl();
} else {
$loginUrl = $facebook->getLoginUrl();
}
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Facebook test</title>
</head>
<body>
<p>
<?php if($user) : ?>
<a href="<?php echo $logoutUrl;?>">Logout</a>
<?php else: ?>
<a href="<?php echo $loginUrl;?>">Login</a>
<?php endif; ?>
</p>
</body>
</html>
将感谢您的帮助!
推荐答案
您不能在iframe中使用身份验证"对话框(为什么?请参见此处:http://facebook.stackoverflow.com/a/10831018/1427878 ). 将target ="_ blank"添加到您的链接中,它应该可以工作. 或者只是嵌入JavaScript SDK&如果您想在没有其他费用的情况下使用弹出窗口,请使用FB.login.
You can't use the auth dialog in an iframe (why? see here: http://facebook.stackoverflow.com/a/10831018/1427878). Add target="_blank" to your links, and it should work. Or just embed the JavaScript SDK & use FB.login, if you want a Popup without further expense.
这篇关于Facebook身份验证对话框未显示在页面选项卡中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!