[英]How do you know if your web application is opening inside Facebook (canvass) or outside (standalone)?
I am creating a login page for my application in PHP. 我正在使用PHP为我的应用程序创建一个登录页面。 My application uses fconnect to login.
我的应用程序使用fconnect登录。 Now,
现在,
If I open the web application standalone (www.acdef.com), it should show fconnect login. 如果我独立打开Web应用程序(www.acdef.com),它应该显示fconnect登录。 if it is opened inside facebook (apps.facebook.com/myapp), it should not show fconnect login and depending on which user, should show either fb permissions or the app landing page.
如果在Facebook(apps.facebook.com/myapp)内部打开,则不应显示fconnect登录名,并且应取决于哪个用户显示fb权限或应用程序登录页面。 Here is what i have done
这是我所做的
if( (isset($_SERVER['HTTP_REFEREER']) && strpos($_SERVER['HTTP_REFEREER'], "facebook.com") !==false) || (isset($this->request->get['ref']) && strpos($this->request->get['ref'], "facebook.com") !==false))
{
// I am in canvass
}
{
// I am not in canvass
}
However, it is not working always. 但是,它并不总是有效。 Many a times even while in canvass, I see fblogin button.
即使在画布中,很多次我也看到fblogin按钮。
Whats the best solution? 什么是最好的解决方案?
-Ajay -阿杰
If your app is opened inside the canvas, you'd have $_REQUEST['signed_request']
set. 如果您的应用是在画布中打开的,则需要设置
$_REQUEST['signed_request']
。
if( isset($_REQUEST['signed_request']) )
{
// I am in canvass
}
else
{
// I am not in canvass
}
You can check whether the app is in an iframe
(fb canvas) or not and act accordingly like so: 您可以检查该应用程序是否位于
iframe
(fb画布)中,并相应地采取如下操作:
<script type="text/javascript">
if(window==window.top){
top.location.href = '<?=$redirect_url?>';
}
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.