Facebook 问题:应用程序转到原始域
我正在使用 PHP 创建一个 facebook 应用程序,面临两个主要问题。
当我单击允许权限时,该应用程序会将我带到我自己的域(存储应用程序的位置),而不是将其加载到 iFrame 中。
有时,当我单击“不允许”时,它仍然让我进入并显示 PHP 错误,而有时(大多数时候),它不让我进入。
可能是什么问题?有什么方法可以以编程方式重定向到权限页面吗?谢谢..
if(empty ($this->session))
{
try
{
$login_url = $this->facebook->getLoginUrl();
header("Location: ".$login_url);
}
catch(Exception $e)
{
header("Location: http://www.facebook.com");
}
}
else
{
try
{
$this->uid = $this->facebook->getUser();
}
catch(Exception $e)
{
header("Location: http://www.facebook.com");
}
}
请注意我所做的重定向是为了尝试解决问题。但没有抛出异常。
I am creating a facebook application with PHP and facing two main problems..
When I click allow on the permission, the app takes me to my own domain (where application is stored) instead of loading it in an iFrame.
Sometimes when I click "Don't allow", it still lets me in and shows a PHP error, while sometimes (most of the times), it doesn't let me in.
What could be the problem? Any way I can programatically redirect to the permissions page? Thank you..
if(empty ($this->session))
{
try
{
$login_url = $this->facebook->getLoginUrl();
header("Location: ".$login_url);
}
catch(Exception $e)
{
header("Location: http://www.facebook.com");
}
}
else
{
try
{
$this->uid = $this->facebook->getUser();
}
catch(Exception $e)
{
header("Location: http://www.facebook.com");
}
}
note the redirects I made were to try to solve the problem. But no exception is thrown.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您想要获取登录网址时,您可以根据需要传递不同的参数。在您的情况下,要返回 Facebook 页面网址,您可以使用
next
参数。这是您修改后的代码:
如果它解决了您的问题,请告诉我:)
When you want to get the login url you can pass different params based on what you need. in your case, to go back to facebook page url you can use the
next
param.This is your code modified:
Let me know if it solves your problem :)
如果页面不在 iFrame 内,我使用这个简单的脚本来应用重定向...
这可能不是一个合法的解决方案,但解决了我的情况。谁知道合法途径请留言。谢谢。
I used this simple script to apply redirect if the page is not inside iFrame...
This might not be a legal solution, but solved the situation for me. Anybody if knows the legal way, please post. Thanks.