无法跳过“publish_permission”,总是要求它

时间:2012-07-11 20:18:26

标签: facebook permissions

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

非常感谢! :)

<!-- 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>

2 个答案:

答案 0 :(得分:3)

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

  • 检查授予的权限,如果缺少某些权限,则重定向回对话框,或
  • 使用JS SDK中指定的某些权限调用FB.login(),类似
如果您没有考虑跳过请求的用户

两者都会导致循环

答案 1 :(得分:0)

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