RailsでFacebook経由でログインする手段としてFacebooker2を使用しようとしています。ただし、Facebook に確実にログインしているにもかかわらず、Facebooker2 の current_facebook_user 関数はどういうわけか nil を返しています。何か案は?ありがとう!
これが私のコードの要点です:
私のコントローラーの1つで:
def check_login
if current_facebook_user.nil?
"This always gets returned, even though I'm logged into Facebook."
else
"This never gets run"
end
end
フェイスブックJS. の行は、上記の関数にFB.Event.subscribe('auth.login', function(response) { ... }
リダイレクトします。check_login
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '123456789012345',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
channelUrl : 'true', // add channelURL to avoid IE redirect problems
xfbml : true // parse XFBML
});
FB.Event.subscribe('auth.login', function(response) {
window.location = "http://www.mysite.com/check_login";
});
}; ( function() {
var s = document.createElement('div');
s.setAttribute('id', 'fb-root');
document.documentElement.getElementsByTagName("body")[0].appendChild(s);
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
s.appendChild(e);
}());
function logout() {
FB.logout();
window.location = 'http://www.mysite.com/logout';
};
</script>