2013-02-26 71 views
0

我正在製作一個應用程序應用程序,它在我的服務器和URL上正常工作,當我嘗試將它作爲「Facebook上的應用程序」註銷後無法加載或登錄。我相信權限範圍會帶來一些問題。Facebook應用程序在服務端工作,而不是作爲「Facebook上的應用程序」工作

服務器的網址:http://veritas.betamass.com

爲「應用程序在Facebook上」方的網址:https://apps.facebook.com/orientacionveritas/

請注意,如果你的服務器上成功登陸,你將能夠看到「應用上Favcebook,如果不是你會得到一個什麼

,使Facebook的連接代碼:

if(!isset($_SESSION['user'])) 
{ 
    //Application Configurations 
    $app_id  = "148133482012457"; 
    $app_secret = "24d0088e17c1dcb33ac6bb424a5d2a5c"; 
    $site_url = "http://veritas.betamass.com/"; 

    try{ 
     include_once "src/facebook.php"; 
    }catch(Exception $e){ 
     error_log($e); 
    } 
    // Create our application instance 
    $facebook = new Facebook(array(
     'appId'  => $app_id, 
     'secret' => $app_secret, 
     'cookie' => true, 
     )); 

    // Get User ID 
    $user = $facebook->getUser(); 
    $access_token = $facebook->getAccessToken(); 
    $facebook->setAccessToken($access_token); 

    // We may or may not have this data based 
    // on whether the user is logged in. 
    // If we have a $user id here, it means we know 
    // the user is logged into 
    // Facebook, but we don�t know if the access token is valid. An access 
    // token is invalid if the user logged out of Facebook. 
    //print_r($user); 
    if($user){ 
     // Get logout URL 

     $logoutUrl = $facebook->getLogoutUrl(); 

    }else{ 
     // Get login URL 
     $params = array(
     'scope' => 'read_stream, publish_stream, email, user_about_me, user_hometown, user_education_history, user_interests', 
     'redirect_uri' => $site_url, 
     ); 
     $loginUrl = $facebook->getLoginUrl($params); 

     /*$loginUrl = $facebook->getLoginUrl(array(
      'scope' => 'read_stream, publish_stream, email, user_about_me, user_hometown, user_education_history', 
      'redirect_uri' => $site_url, 
      ));*/ 
    } 

幫助!

回答

0

如果用戶不存在或沒有會話,您需要先讓他們登錄。您的代碼沒有考慮到這一點。

如果會話/ $facebook->getUser()返回false,請嘗試將用戶重定向到$facebook->getLoginUrl()

相關問題