Search code examples
facebookiframefbml

How Do I Create a Facebook App That I Can Add to a Page and Only Likers Will See


I have a Facebook page that I created and I want to create a contest app that only likers can see. I was able to do this in the past using FBML but ever since Facebook has stopped using FBML, I can't seem to do this with IFrame apps. Can anyone help me out?

Thanks!


Solution

  • Well, we can give you guidance. You can either develop the whole thing yourself or use a pre-built product like the one provided by Strutta (not free!).

    Now how to develop a contest system is up to you, but how to make it available only to fans is easy. You just need to read the signed_request, look for the page parameter and check if the liked field is set or not. This is how to do it in PHP:

    <?php
    $signed_request = $_REQUEST["signed_request"];
    list($encoded_sig, $payload) = explode('.', $signed_request, 2);
    $data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);
    
    if (empty($data["page"]["liked"])) {
        echo "You are not a fan!";
    } else {
        echo "Welcome back fan!";
    }
    ?>
    

    You may need to take a look at the Promotions Guidelines.