2012-10-15 72 views
3

在heroku上運行我的Facebook應用程序時有一些未知問題Facebook,登錄重新加載循環

問題現在與訪問令牌有關。我不知道什麼 這似乎是在應用程序中的東西破壞我的訪問令牌。原因是當我嘗試登錄到應用程序,然後使用資源管理器時,它說im已註銷或acces令牌已過期。但如果我調試它,它說它有效2個小時。 此外,我登錄後,頁面無法重新加載。

Aparently該網站不斷重新加載..並反覆更新。這在頁面登錄時停止

錯誤似乎最近出現..上週沒有它。我猜這個問題會出現在這裏,但我找不到它。 如果您發現任何可能導致問題的內容,請將其提示。謝謝

require_once('sdk/src/facebook.php'); 

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

$user_id = $facebook->getUser(); 
if ($user_id) { 
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(); 
} 
} 

<script type="text/javascript"> 
    window.fbAsyncInit = function() { 
    FB.init({ 
     appId  : '<?php echo AppInfo::appID(); ?>', // App ID 
     channelUrl : '//<?php echo $_SERVER["HTTP_HOST"]; ?>/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) { 
    console.log (response.status); 
    //this is useful if you want to avoid the infinite loop bug 
    //it only reloads page when you log in 
    if (response.status != 'connected') { 
     FB.Event.subscribe('auth.login', function(response) { 
      // We want to reload the page now so PHP can read the cookie that the 
      // Javascript SDK sat. But we don't want to use 
      // window.location.reload() because if this is in a canvas there was a 
      // post made to this page and a reload will trigger a message to the 
      // user asking if they want to send data again. 
      window.location = window.location; 
      //Im using the window.location.reload() 
      //window.location.reload(); 
     }); 
    } 
}); 
FB.Canvas.setAutoGrow(); 
}; 

    // Load the SDK Asynchronously 
    (function(d, s, id) { 
    var js, fjs = d.getElementsByTagName(s)[0]; 
    if (d.getElementById(id)) return; 
    js = d.createElement(s); js.id = id; 
    js.src = "//connect.facebook.net/en_US/all.js"; 
    fjs.parentNode.insertBefore(js, fjs); 
    }(document, 'script', 'facebook-jssdk')); 
</script> 
<header class="clearfix"> 
    <?php if (isset($basic)) { ?> 
    <p id="picture" style="background-image: url(https://graph.facebook.com/<?php echo he($user_id); ?>/picture?type=normal)"></p> 

    <div> 
    <h1>Welcome, <strong><?php echo he(idx($basic, 'name')); ?></strong></h1> 
    <p class="tagline"> 
     This is your new app for sorting events 
     <a href="<?php echo he(idx($app_info, 'link'));?>" target="_top"><?php echo he($app_name); ?></a> 
    </p> 

    <div id="share-app"> 
     <p>Share this app:</p> 
     <ul> 
     <li> 
      <a href="#" class="facebook-button" id="postToWall" data-url="<?php echo AppInfo::getUrl(); ?>"> 
      <span class="plus">Post to Wall</span> 
      </a> 
     </li> 
     <li> 
      <a href="#" class="facebook-button speech-bubble" id="sendToFriends" data-url="<?php echo AppInfo::getUrl(); ?>"> 
      <span class="speech-bubble">Send Message</span> 
      </a> 
     </li> 
     <li> 
      <a href="#" class="facebook-button apprequests" id="sendRequest" data-message="Prøv den her"> 
      <span class="apprequests">Send Requests</span> 
      </a> 
     </li> 
     </ul> 
    </div> 
    </div> 
    <?php } else { ?> 
    <div> 
    <h1>Welcome</h1> 
    <div class="fb-login-button" data-scope="user_likes,user_photos,user_events,friends_events, user_hometown,user_location,user_interests,user_about_me,user_education_history,friends_location,read_friendlists"></div> 
    </div> 
    <?php } ?> 
</header> 
<section id="get-started"> 
<?php 
//echo (idx($app_get_events[1], 'id'); 
?> 

</section> 

回答

0

你使用什麼瀏覽器?新的Safari版本不接受來自iframe的cookie。所以請檢查會話是否正常工作,以及是否可以創建Cookie。

+0

嗨,即時通訊使用火狐W7 :) – user1748254

+0

和會議呢?它工作正常嗎?你能夠創建cookie嗎? –

+0

不知道如何檢查它馬克:/我應該只是嘗試設置一些其他的cookie或只是做一個print_r嗎? – user1748254