1

这是一个可选权限,但我无法在我的画布应用程序中跳过它,当我在此权限上单击“跳过”时,我的页面被重定向以一次又一次地询问此权限。任何人都知道为什么会这样?

非常感谢!:)

<!-- BEGINNING OF THE INDEX.PHP CODE -->
<?php

  //SOLVES INFINITE LOOP ON IE
  header('P3P: CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');

  // Enforce https on production
  if (substr(AppInfo::getUrl(), 0, 8) != 'https://' && $_SERVER['REMOTE_ADDR'] != '127.0.0.1') {
    header('Location: https://'. $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    exit();
  }

  $facebook = new Facebook(array(  'appId'  => AppInfo::appID(),  'secret' => AppInfo::appSecret(), ));

  $user_id = $facebook->getUser();

  //Check if we have an user_id
  if ($user_id!="0") {

        try {
          // Fetch the viewer's basic information
          $basic = $facebook->api('/me');
        } catch (FacebookApiException $e) {
          // If the call fails we check if we still have a user. The user will be
          // cleared if the error is because of an invalid accesstoken
          if (!$facebook->getUser()) {
            header('Location: '. AppInfo::getUrl($_SERVER['REQUEST_URI']));
            exit();
          }
        }

  } else { 

    // If the user is not connected to the application, redirect the user to authentication page 
    $login_url = $facebook->getLoginUrl(array('redirect_uri' => "https://apps.facebook.com/APP_NAME_SPACE/",'scope' =>  'publish_stream,email','display' => 'page')); 

    ?><html xmlns="https://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
       <head>
       </head>
       <body>
       <script type="text/javascript"> top.location.href='<?php echo $login_url; ?>'</script> 
      </body>
      </html><?php   

        exit();
  }

  if(isset($basic)) {

    $locale=idx($basic, 'locale');
    $name=he(idx($basic, 'name'));
    $email=he(idx($basic, 'email'));

  } else {

    // IF the user is not loggin on facebook, redirect the user to facebook login page
    ?>
  <script type="text/javascript">
    var oauth_url = 'https://www.facebook.com/dialog/oauth/';
    oauth_url += '?client_id=APP_ID';
     oauth_url += '&redirect_uri=' + encodeURIComponent('https://apps.facebook.com/APP_NAME_SPACE/');
     oauth_url += '&scope=publish_stream,email'
     window.top.location = oauth_url;
    </script>
<?php
    exit();
    //ends execution if there's no login
  }


  ?>
<html>
 // APP HTML CODE
</html>
4

2 回答 2

3

如果没有看到您的身份验证代码,很难确定,但我相信您有

  • 检查授予了哪些权限,如果缺少某些权限,则重定向回对话框,或者
  • 以 JS SDK 中指定的某些权限调用FB.login(),类似于

如果您不考虑用户跳过请求,两者都会导致循环

于 2012-07-11T20:20:48.137 回答
0

显然,他正在使用 facebook sdk 库。我从来没有听说过跳过权限。当需要构建用于身份验证的 URL 时,您可以将它们设置在适当的函数中。检索登录身份验证流程是值得的,但尝试oauth_url += '&scope=email'而不是您所拥有的?或者,您可以尝试构建没有范围的 oauth url,并查看应用程序要求的权限。如果它要求特定的权限,请检查登录功能,看看是否已经设置了一些权限。如果我没记错的话,它应该在 facebook.php 文件中。

于 2013-12-13T17:12:23.647 回答