问题描述
我的网站上有一个像按钮(用户喜欢fb粉丝页面)。
I have a like button on my website (which is for users to like the fb fan page).
如果用户点击了,我查看是否甚至被解雇(事件订阅),然后向他们显示一些内容。
If the user clicks like, I check to see if the even has been fired (event subscribe), and then display some content to them.
我真正感谢的帮助如下:
如果用户登录到Facebook ,并且他们已经喜欢该页面,我希望它显示您已经是粉丝!并显示内容。 (而不是显示灰色的按钮)
If the user is logged in to facebook AND they already like the page, I want it to display "You're already a fan!" and show the content. (rather than displaying the greyed out like button)
或
如果用户没有登录到Facebook ,他们点击相似的按钮,我希望它显示你已经是粉丝!并显示内容。 (而不是显示灰色的按钮)
If the user is not logged in to facebook and they click the like button, I want it to display "You're already a fan!" and show the content. (rather than displaying the greyed out like button)
编辑:有人,我已经在SO上研究过这个,并且发现了类似的问题,但并不完全相同。也许我是错误的,但如果有人可以提供一个描述我的确切问题的链接,那么这将是一个更有帮助的问题。我已经检查了以下内容:
edit: Guys, I've researched this on SO and have found similar questions but not quite what I'm after. Maybe I'm mistaken but if someone can provide a link to one which describes my exact problem, it would be a lot more helpful than a - on the question. I have checked the following:
Check if the user is connected to facebook and then check if he liked a page
Facebook Like Box: How to detect if user already liked the page?
Facebook LIKE button hiding when page is already LIKED by user
How to check whether user has liked the page or not using php/javascript
Check if user already likes fanpage
推荐答案
如果您使用Facebook php API。我已经想出了这个简短的功能,你可以将base_facebook.php文件包含在BaseFacebook中。
If you use the facebook php API. i've came up with this short function that u can include inside the base_facebook.php file into the class BaseFacebook.
public function userIsFan() {
$sr = $this->getSignedRequest();
if($sr && is_array($sr)){
if(array_key_exists('page', $sr)){
return $sr['page']['liked'] == 1;
}
}
return 0;
}
这篇关于如何检查IF用户是否有ALREADY喜欢的Facebook页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!