2012-07-11 33 views
1

這是一個可選的權限,但我無法在我的畫布應用程序中跳過它,當我點擊這個權限的「跳過」時,我的頁面被重定向到一次又一次地詢問此權限然後再次。任何人都知道爲什麼會發生這種情況?無法跳過「publish_permission」,總是要求輸入

非常感謝! :)

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

回答

3

沒有看到您的授權碼是很難確定,但我有信心,你有

  • 檢查,看的權限被授予什麼和重定向回到對話如果某些缺失,或
  • FB.login()的調用與在JS SDK指定的某些權限,這樣的事情

都將導致一個循環如果y ou不考慮跳過請求的用戶

+0

非常感謝您的回答,Igy!我相信這不可能。你能看看我的代碼嗎?我在原始帖子上編輯過它。此外,值得注意的是,在我的畫布頁面定義中,我定義了Authenticated Referrals,通過電子郵件發送「User&Friend Permissions」,並通過publish_stream發送「Extended Permissions」。 – 2012-07-11 21:56:12

0

顯然,他使用的是Facebook sdk庫。我從來沒有聽說過跳過權限。在需要構建用於身份驗證的URL時,可以將它們設置爲適當的功能。這將是值得檢索登錄身份驗證流程,但嘗試oauth_url += '&scope=email',而不是你有什麼?或者,您可以嘗試構建不帶範圍的oauth url,並查看應用程序詢問的權限。如果它要求特定的權限,請檢查登錄功能並查看是否已經設置了某些權限。如果我沒有記錯的話,應該是在facebook.php文件中。