turmeric
turmeric

Reputation: 543

"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?

Upvotes: 3

Views: 383

Answers (2)

Art
Art

Reputation: 5924

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

Upvotes: 3

mrtom
mrtom

Reputation: 2156

Use the JavaScript SDK and subscribe to the 'edge.create' event. https://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/ has an example.

However think hard before doing this, and do A-B testing. It's a pretty crappy user experience and you'll usually get a lot of drop off

Upvotes: 1

Related Questions