2012-08-07 93 views
0

我在Facebook上創建了一個應用程序,但在我要求權限之前,我想檢查用戶是否已登錄並執行一些任務。檢查用戶是否登錄沒有要求權限 - facebook

我嘗試這樣做:

$facebook = new Facebook(array(
      'appId' => $app_id, 
      'secret' => $secret, 
      'cookie' => true 
     )); 


    $user = $facebook->getUser(); 
    if ($user) { 
     echo 'logged in'; 
    } else { 
     echo 'not logged in'; 
    } 

但它總是要求的權限。

+0

絕對沒有在最少的代碼,可能導致要求的權限。 – CBroe 2012-08-07 13:17:55

+0

我知道,但他要求提供個人信息:\ – Mek 2012-08-07 13:33:19

+0

誰是「他」? 再次說明:您的代碼中甚至沒有實現登錄/連接到您的應用程序,因此您的問題絕對無法通過您發佈的代碼重現。 – CBroe 2012-08-07 13:42:45

回答

1

我用這個代碼:

<div id="fb-root"></div> 
<script> 
window.fbAsyncInit = function() { 
    FB.init({ 
     appId  : 'xxxxxxx', // App ID 
     channelUrl : 'YOUR_URL/channel.html', // Channel File 
     status  : true, // check login status 
     cookie  : true, // enable cookies to allow the server to access the session 
     xfbml  : true // parse XFBML 
    }); 


    FB.getLoginStatus(function(response) { 
     if (response.status === 'connected') { 
        //User Is Logged In and authorized 
      var uid = response.authResponse.userID; 
     } else if (response.status === 'not_authorized') { 
      //User is Logged in and not authorized 
     } else { 
      // the user isn't logged in to Facebook. 
     } 
    }); 
}; 
</script> 
相關問題