How to check IF user has ALREADY liked the facebook page?

前端 未结 2 995
我寻月下人不归
我寻月下人不归 2020-12-06 06:57

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)

2条回答
  •  盖世英雄少女心
    2020-12-06 07:26

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

提交回复
热议问题