问题描述
我的网站上有一个facebook likebox(不是iframe应用),我需要创建封闭内容。我理解FB.Event.subscribe使用edge.create和edge.remove但我真正需要的是知道用户是否已经喜欢该页面,而不仅仅是他们成为粉丝或不再是粉丝。有没有什么我可以看到作为回调可能来自xfbml.render?
I have a facebook likebox on my site (not an iframe app) where I need to create gated content. I understand the FB.Event.subscribe using edge.create and edge.remove but what I really need is to know if a user already likes the page not simply if they became a fan or stopped being a fan. Is there anything I can see as a callback maybe from the xfbml.render?
我受限于(由我的公司)使用前端语言,这意味着javascript真的是我的此时只有选项。我很乐意使用signed_request选项,但最好的我可以说它似乎只能通过服务器端语言访问。
I am limited (by my company) to using front end languages, meaning javascript is really my only option at this point. I would gladly use the "signed_request" option but best I can tell that seems to be only accessible via server side languages.
有没有办法让我确定是否有人已经只使用javascript喜欢一个页面?
Is there any way for me to determine whether someone already "Likes" a page using only javascript?
推荐答案
是的,您可以使用FB Javascript sdk在javascript中完成此操作。
Yes, you can do this completely in javascript using the FB Javascript sdk.
function RunLikeCheck() {
var likeId = 'yourLikeIdHere';
FB.api({
method: 'fql.query',
query: 'SELECT uid FROM page_fan WHERE page_id = ' + likeId + ' AND uid = me()'
},
function (response) {
if (response.length == 1) {
$("#HasLiked").val('true');
$('#frmAllow').submit();
}
else {
$("#HasLiked").val('false');
$('#frmAllow').submit();
}
}
);
}
现在假设您已经让用户登录并拥有正确的权限。
Now this is assuming that you already have the user logged in and have the correct permissions.
这篇关于Fan-Gate,Like-Gate,show-to-connections,javascript和like box?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!