1
我有問題註銷使用考拉寶石,並且想知道他們是否有關係。Facebook考拉寶石 - 登出
下面是我的Javascript代碼:
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '310521258992725', // App ID
channelUrl : '//localhost:3000/channel', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
// Additional initialization code here
// whenever the user logs in, we refresh the page
FB.Event.subscribe('auth.login', function() {
setTimeout('document.location.reload()',0);
});
FB.logout(function(response) {
FB.Auth.setAuthResponse(null, 'unknown');
setTimeout('document.location.reload()',0);
});
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
</script>
下面是我的Facebook標籤:
<div id="fb-root"></div>
我的註銷代碼:
<a href="/" onclick="FB.logout();">Logout</a>
登錄完美的作品,我可以執行API通話沒有問題。但是,我退出後,我收到以下錯誤:
OAuthException: Error validating access token: The session is invalid because the user logged out. app/controllers/application_controller.rb:58: in 'fbookinvite_check'
下面是我的fbookinvite_check代碼:
def fbookinvite_check
unless @facebook_cookies.nil?
@access_token = @facebook_cookies["access_token"]
@graph = Koala::Facebook::GraphAPI.new(@access_token)
if [email protected]? == true
@friends = @graph.get_object("/me/friends")
end
end
end
的問題似乎是,Cookie是一種訪問令牌無效,@graph在重定向後不顯示爲零。如果我刷新,那麼頁面加載沒有問題,但是當我註銷時出現錯誤。
也許有一種方法可以在不關閉應用程序的情況下捕獲@ graph.get_object錯誤?
任何建議將不勝感激!
對不起,不知道我照做。有沒有可能介意在代碼中給出一個例子?謝謝 – user749798 2012-08-16 05:32:33
感謝您的幫助! – user749798 2012-08-17 14:44:31