Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 926
Gazzzzza Avatar asked Sep 13 '11 06:09

Gazzzzza


People also ask

How do you see someones likes on Facebook 2022?

Click the magnifying glass icon at the upper corner of your screen and enter the name of the Facebook user in the search bar. Choose the “About info” to be directed to the pages that they liked. In the likes section, you will see the pictures, videos and other content that the user liked. Click the “View all”.

Why can't I see all the likes on someone's Facebook page?

If the number of likes is not the same as the number of user profiles that you see after clicking on the number, either someone who liked it blocked you, you blocked him/her or they deactivated their profile. If someone has deactivated his/her profile, there likes count also will not show.

How do you see what people liked on Facebook?

It's at the top of your friend's profile, but below their cover photo. A menu will expand with more options. Click Likes on the menu. This opens your friend's Likes page, where you'll find all of the movies, TV shows, artists, books, restaurants, and other Pages they've liked on Facebook.


1 Answers

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;
}
like image 82
gabo bernal Avatar answered Nov 09 '22 07:11

gabo bernal