简体   繁体   English

FBML Canvas应用程序身份验证

[英]FBML Canvas Application Authentication

I'm modifying an FBML canvas app to use the new PHP SDK and authentication instead of the old REST api. 我正在修改FBML canvas应用程序以使用新的PHP SDK和身份验证,而不是旧的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: 但是,如果我对任何非相对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.

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? 如果我需要使用最新的PHP SDK在FBML canvas应用上进行身份验证,如何正确重定向到请求扩展权限的应用登录页面?

Looks like you cannot use a server side redirect (header()) to push user to the auth page. 看来您无法使用服务器端重定向(header())将用户推送到auth页面。 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();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM