doutan3040 2011-09-13 06:33
浏览 29

如何检查IF用户是否已经喜欢Facebook页面?

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.

What I would really appreciate help with is the following:

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)

OR

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)

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

  • 写回答

2条回答 默认 最新

  • duanlu9816 2012-10-23 00:08
    关注

    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;
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?