Fan-Gate、Like-Gate、show-to-connections、带有 javascript 和 Like 框?

发布于 2024-10-23 14:29:59 字数 334 浏览 4 评论 0原文

我的网站上有一个 facebook Likebox(不是 iframe 应用程序),我需要在其中创建门控内容。我了解使用edge.create和edge.remove的FB.Event.subscribe,但我真正需要的是知道用户是否已经喜欢该页面,而不仅仅是他们成为粉丝或不再是粉丝。有什么我可以看到的回调可能来自 xfbml.render 吗?

我(被我的公司)限制使用前端语言,这意味着 javascript 实际上是我目前唯一的选择。我很乐意使用“signed_request”选项,但据我所知,这似乎只能通过服务器端语言访问。

有什么方法可以让我仅使用 javascript 来确定某人是否已经“喜欢”某个页面?

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?

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.

Is there any way for me to determine whether someone already "Likes" a page using only javascript?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

泛滥成性 2024-10-30 14:29:59

是的,您可以使用 FB Javascript sdk 在 javascript 中完全完成此操作。

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();
                    }
                }
            );
}

现在假设您已经让用户登录并拥有正确的权限。

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.

神回复 2024-10-30 14:29:59

下面是一些额外的示例 javascript 代码,用于实现不需要 FB.api 调用的点赞门(但确实需要用户每次访问页面时重新点赞)。

http://linksy.me/viral-gate

Here is some additional sample javascript code for implementing a like gate that does not require the FB.api call (but does require the user to re-like every time they visit the page).

http://linksy.me/viral-gate

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文