Search code examples
facebookfancyboxfacebook-likelightbox

"Like" Gating Content on a Non-Facebook Webpage


Goal: To create a Facebook "Like" button interstitial that only disappears after a "Like"

I'm hoping to create an interstitial with a like button that disappears when a user clicks like. Is this possible - how would I go about accomplishing this?


Solution

  • You can do this. To check if a user has already liked your page you can do:

    FB.api("/{page_id}/members/{user_id}", function(r) { if(r.data.length > 0) { //liked! } });
    

    However, there is a bug right now that breaks this API(http://developers.facebook.com/bugs/344295515590822?browse=search_4f34b7fc320fa8d06106500).

    You can catch a user like this:

    FB.Event.subscribe("edge.create", function(w) {
        if(w === "{fan_url}") {
             // Liked my page
        }
    });