Search code examples
facebookherokufacebook-like

Show text when user likes a FB page


We're trying to do some things on Facebook but to be honest we have no idea where to start.

We have a Facebook application which doesn't require any authorization. It's basically just a static page showing some of our information at the moment. We added it to a page as a tab.

We want to show some welcome text when a user likes our page. How should we go about this? I haven't used the Facebook SDK before so I'm completely lost.

Can we do this through the JS SDK? Check if a user has already liked our page and show a welcome message, otherwise show the like button? We're working with Heroku FB apps, not sure if that's important.

I'm not looking for complete example code, just some pointers would be nice.

Thanks in advance.


Solution

  • What you're looking for is a fan gate.

    Here's a decent explanation:

    http://www.hyperarts.com/blog/customizing-facebook-iframe-application-signed_request_reveal_tab/

    $signed_request = $facebook->getSignedRequest();
    
    $like_status = $signed_request["page"]["liked"];
    
    if ($like_status) {
      echo "You like us";
    }
    else {
      echo "You don't like us yet";
    }