Search code examples
facebookfacebook-likefacebook-page

how to check if visitor liked my facebook fanpage. private website not facebook iframe tabs


Is it possible to check if the visitor of my private Website liked my Facebook Fanpage? I found many posts for Facebook Iframe-Tabs but not for private Website owner.


Solution

  • You must have the user_likes permission, so you can query the likes the user already has.

    And then using the javascript sdk you can achieve it by doing this:

    function isPageLiked(YOUR_VALID_TOKEN) {
        token = YOUR_VALID_TOKEN;
        FB.api('/me/likes/YOUR_PAGE_ID', function(response) {
            if(response.data.length){
                //the user likes your page do something here
            }
        }, {access_token: token});
    
    }