我想检查用户是否喜欢某个页面,并根据它显示该网站的内容! 以下是使用FQL的代码。有没有办法使用Javascript SDK?
$(document).ready(function(){
FB.login(function(response) {
if (response.session) {
var user_id = response.session.uid;
var page_id = "1553725881514063"; //Swoopshows page id
var fql_query = "SELECT uid FROM page_fan WHERE page_id = "+page_id+"and uid="+user_id;
var the_query = FB.Data.query(fql_query);
the_query.wait(function(rows) {
if (rows.length == 1 && rows[0].uid == user_id) {
alert("Liked");
//here you could also do some ajax and get the content for a "liker" instead of simply showing a hidden div in the page.
} else {
alert("not liked");
//and here you could get the content for a non liker in ajax...
}
});
} else {
// user is not logged in
alert("Please Login to continue");
}
});
});
另外,在我的SDK启动中,我已经提到版本为2.0。这仍然不起作用。任何帮助将不胜感激。
答案 0 :(得分:4)
这不再起作用了,因为Facebook令人沮丧,并且#34;喜欢门控"内容。
见
'喜欢'属性将不再在“signed_request”中返回。今天之后创建的Page Tab应用程序的对象。从2014年11月5日起,'喜欢'物业将永远返回真实'无论该人是否喜欢该页面。
由于您需要user_likes
权限来确定用户是否喜欢该网页,因此需要进行应用审核,因此您很可能无法获得批准的权限:
不允许:根据某人是否喜欢某个网页,对您的应用或应用内的某些内容进行访问。