不要为已经喜欢的人显示Facebook的按钮 [英] Don't display facebook like button for those who already liked it

查看:135
本文介绍了不要为已经喜欢的人显示Facebook的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想为那些不喜欢该页面的用户显示一个Facebook的按钮。所以,当一个用户已经是页面的粉丝时,类似的按钮将不会被显示。

I want to display a Facebook like button for a page only for those who didn't like that page. So, when a user is already a fan of the page , the like button will not be shown.

我做了大量的研究,发现我需要实现Facebook连接并获取 user_likes 权限,并检查所连接的用户是否具有列表中的页面。这是一个工作示例。 http://www.fbrell.com/fb.api/does-像

I did a lot of research and I found that I need to implement Facebook connect, and fetch the user_likes permission and check if the connected user has the page in his list. This is a working example http://www.fbrell.com/fb.api/does-like

Basicaly,我需要这样做的代码:

Basicaly, I need the code that will do this :

当用户点击连接时,内容将被更改,如果连接的用户过去不喜欢,则会显示Facebook的按钮。

When the user clicks on connect, the content will be changed and the Facebook like button will be shown if the connected user didn't like it in the past.

推荐答案

实施 JavaScript SDK



在JS SDK的初始化过程中,确保将 xfbml 设置为false,以免插件自动呈现。您必须请求 user_likes 权限这意味着您将不得不将您的网站与Facebook应用程序相关联。这样Facebook可以跟踪谁在请求什么数据。您可以使用 Fb.login() 方法来请求权限并验证您的用户。

Implement the JavaScript SDK

During the initialization of the JS SDK, make sure to set xfbml to false, so that the plugin will not be rendered automatically. You'll have to request the user_likes permission which means that you are going to have to associate your site with a Facebook application. This is so that Facebook can keep track of who is requesting what data. You can use the Fb.login() method to request permissions and authenticate your users.

一旦你拥有JavaSctipt SDK,你可以通过

Once you have the JavaSctipt SDK you can simply make a call to the API via


  • 图表

    FB.api('me / likes / PAGE_ID')

FQL

FB.api(fql?q ='SELECT + uid + FROM + page_fan + WHERE + uid = me()+ AND + page_id = PAGE_ID)

如果这些返回数据您知道不显示类似的插件。但是,如果用户尚未喜欢该页面,则这些调用将返回空的结果,然后您可以调用 FB.XFBML.parse() 方法来呈现类似的插件。

If those return data you know not to display the like plugin. However, if the user has not liked the page yet, those calls will return empty results and then you can call the FB.XFBML.parse() method to render the like plugin.

这篇关于不要为已经喜欢的人显示Facebook的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆