我已经阅读了很多相关的话题在这里关于这个问题,但我仍然不能够做这样的事检查用户是否喜欢页面或不
http://www.facebook.com/Dominos/app_252492331452398
下面是我使用
代码这是我的问题。
- 所以我已经登录到我的Facebook页面
- 如果我去上面的多米诺骨牌网址,我可以相同的或不同的页面。多米诺骨牌的内容根据我是否喜欢或不同于网页而改变。但他们并没有要求我们再次登录
在我的代码下面,虽然我已经登录了我的脸书。我没有访问我的用户信息,直到我点击登录按钮并在提供的弹出窗口中再次登录。随着多米诺骨牌在做,我怎么能跳过这一步。我越来越response.status作为NOT_AUTHORIZED
- 我知道一旦我登录,我可以这样做,以检查用户是否喜欢我的网页或不
VAR的查询= FB.Data。查询('从page_fan选择page_id,其中uid ='+ response.authResponse.userID +'和page_id ='+ PAGE_ID);
下面是代码
<!DOCTYPE html>
<html>
<head>
<title>Fbjquery</title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
<div id="fb-root"></div>
<h2>Updated JS SDK example</h2><br />
<div id="user-info"></div>
<p><button id="fb-auth">Login</button></p>
<script>
window.fbAsyncInit = function() {
FB.init({ appId: 'App_ID',
status: true,
cookie: true,
xfbml: true,
oauth: true});
function updateButton(response) {
var button = document.getElementById('fb-auth');
console.log("inside update button "+response.authResponse);
if (response.authResponse) {
console.log(response.authResponse);
//user is already logged in and connected
var userInfo = document.getElementById('user-info');
FB.api('/me', function(response) {
userInfo.innerHTML = '<img src="https://graph.facebook.com/'
+ response.id + '/picture">' + response.name;
button.innerHTML = 'Logout';
});
button.onclick = function() {
FB.logout(function(response) {
var userInfo = document.getElementById('user-info');
userInfo.innerHTML="";
});
};
} else {
//user is not connected to your app or logged out
button.innerHTML = 'Login';
button.onclick = function() {
FB.login(function(response) {
if (response.authResponse) {
FB.api('/me', function(response) {
var userInfo = document.getElementById('user-info');
userInfo.innerHTML =
'<img src="https://graph.facebook.com/'
+ response.id + '/picture" style="margin-right:5px"/>'
+ response.name;
});
} else {
//user cancelled login or did not grant authorization
}
}, {scope:'email'});
}
}
}
// run once with current status and whenever the status changes
FB.getLoginStatus(updateButton);
FB.Event.subscribe('auth.statusChange', updateButton);
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol
+ '//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
</body>
</html>
相关/ DUP:http://stackoverflow.com/questions/6246449/facebook-how-to-check-if-user-has-liked-page-and-show-content – ripper234 2012-10-23 15:39:55