简体   繁体   English

当用户已经喜欢页面时,Facebook LIKE按钮隐藏

[英]Facebook LIKE button hiding when page is already LIKED by user

I'm trying to create a page on my site where the Like button should be hidden if the user already likes the page. 我正在尝试在我的网站上创建一个页面,如果用户已经喜欢该页面,则应该隐藏“赞”按钮。 If I can't hide it, then maybe there's a way to get a callback when the like button is rendered with a user who already likes the page. 如果我无法隐藏它,那么当已经喜欢该页面的用户呈现“喜欢”按钮时,也许有一种方法可以获取回调。 This way I can hide/reveal the iframe myself. 这样我就可以自己隐藏/显示iframe。

Any clues? 有什么线索吗?

Howie 豪伊

Assuming you can echo the ids of the like buttons to the page for the likes you want hidden/get from a JSON call. 假设您可以在页面上呼应点赞按钮的ID,以查找要从JSON调用中隐藏/获取的点赞。

var hideLikes = ["#like1", "#like2", "#like3", "#like4", "#like5"]; 
var hideLikesSelector = hideLikes.join(",");
$(hideLikesSelector).hide();

You should not hide the Like button as you're suggesting. 您不应该像建议的那样隐藏“赞”按钮。 It is against Facebook policy to hide it after the user has liked the thing in question, you should give them the opportunity to unlike it if they chose to do so. 在用户喜欢有问题的东西之后将其隐藏是违反Facebook的政策,如果他们选择这样做,则应给他们提供与它不同的机会。

@Graphain, why are you commenting? @Graphain,为什么要发表评论? You have no valid input. 您没有有效的输入。

@Others, I have been trying this too and had it working by looking at the opacity of certain tag's classes but it no longer works again. @Others,我也一直在尝试这种方法,通过查看某些标签类的不透明度使它起作用,但是它不再起作用。 You can make an api call to /me/likes and go through the returned array to look at each name or id... 您可以对/ me / likes进行api调用,并通过返回的数组查看每个名称或ID ...

Hope that helps. 希望能有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM