FBML Canvas 应用程序身份验证

发布于 2024-09-30 06:42:57 字数 887 浏览 0 评论 0原文

我正在修改 FBML 画布应用程序以使用新的 PHP SDK 和身份验证,而不是旧的 REST api。

现在我正在尝试使用此代码片段:

$me = null;
// Session based API call.
if ($session) {
  try {
    $uid = $facebook->getUser();
    $me = $facebook->api('/me');
  } catch (FacebookApiException $e) {
    error_log($e);
  }
}
// login or logout url will be needed depending on current user state.
if ($me) {
} else {
    $loginUrl = $facebook->getLoginUrl(array('req_perms' => 'user_birthday, publish_stream, email'));
    header('Location: '.$loginUrl);
}

但是,如果我对任何不相关的 URL 使用 php 标头函数,则会收到此错误:

Application Temporarily Unavailable
The URL [https://www.facebook.com/login.php?.........] is not valid.

Sorry, the application you were using is experiencing a problem. Please try again later.

如果我需要使用最新的 PHP SDK 在我的 FBML 画布应用程序上进行身份验证,如何正确重定向到请求扩展权限的应用程序登录页面?

I'm modifying an FBML canvas app to use the new PHP SDK and authentication instead of the old REST api.

Right now I'm attempting to use this snippet:

$me = null;
// Session based API call.
if ($session) {
  try {
    $uid = $facebook->getUser();
    $me = $facebook->api('/me');
  } catch (FacebookApiException $e) {
    error_log($e);
  }
}
// login or logout url will be needed depending on current user state.
if ($me) {
} else {
    $loginUrl = $facebook->getLoginUrl(array('req_perms' => 'user_birthday, publish_stream, email'));
    header('Location: '.$loginUrl);
}

However if I use the php header function for any URL that isn't relative, I get this error:

Application Temporarily Unavailable
The URL [https://www.facebook.com/login.php?.........] is not valid.

Sorry, the application you were using is experiencing a problem. Please try again later.

If I need to have authentication on my FBML canvas app using the latest PHP SDK, how do I properly redirect to the app login page that requests the extended permissions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

九局 2024-10-07 06:42:57

看起来您无法使用服务器端重定向(header())将用户推送到身份验证页面。我现在正在使用这个:

function redirect($url)
{
    echo '<script>top.location="' . $url . '";</script>';
    //echo '<fb:redirect url="' . $url . '"></fb:redirect>';
    //header("location:$url");
    exit();
}

Looks like you cannot use a server side redirect (header()) to push user to the auth page. I'm using this at the moment:

function redirect($url)
{
    echo '<script>top.location="' . $url . '";</script>';
    //echo '<fb:redirect url="' . $url . '"></fb:redirect>';
    //header("location:$url");
    exit();
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文