我对likegate使用以下代码,但弹出登录对话框被阻止。我的一个朋友说我可以用fb订阅活动。谁有人这样做了?除非有办法欺骗盒子打开显示:页面而不是弹出窗口。
任何帮助表示赞赏。
FB.getLoginStatus(function(response) {
var page_id = "XXX";
if (response && response.authResponse) {
var user_id = response.authResponse.userID;
var fql_query = "SELECT uid FROM page_fan WHERE page_id = "+page_id+"and uid="+user_id;
FB.Data.query(fql_query).wait(function(rows) {
if (rows.length == 1 && rows[0].uid == user_id) {
console.log("LIKE");
$('#container_like').show();
} else {
console.log("NO LIKEY");
$('#container_notlike').show();
}
});
} else {
FB.login(function(response) {
if (response && response.authResponse) {
var user_id = response.authResponse.userID;
var fql_query = "SELECT uid FROM page_fan WHERE page_id = "+page_id+"and uid="+user_id;
FB.Data.query(fql_query).wait(function(rows) {
if (rows.length == 1 && rows[0].uid == user_id) {
console.log("LIKE");
$('#container_like').show();
} else {
console.log("NO LIKEY");
$('#container_notlike').show();
}
});
} else {
console.log("NO LIKEY");
$('#container_notlike').show();
}
}, {scope: 'user_likes'});
}
});
};
答案 0 :(得分:1)
我认为PHP的方式,这是更好,更容易...这里是所有人尝试的代码:)
$facebook = new Facebook(array(
'appId' => 'XXXXXX',
'secret' => 'XXX',
'cookie' => true
));
$sr = $facebook->getSignedRequest();
?>
<?php if ($sr['page']['liked']): ?>
<-- STUFF IF A FAN -->
<?php else: ?>
<-- STUFF IF NOT A FAN -->
<?php endif; ?>