May 3rd, 2012
Hiding content on your Facebook welcome page can be a great incentive for people to like your page to get the hidden content. Since Facebook depreciated FBML we now have to use iFrames. This is pushing it further into the realms of developers rather than end users.
SEE LIVE EXAMPLE
How To Do It?
Step 1 – Create A PHP file and create the iFrame
If you don’t have an iFrame and php file already look at: How To Add An iFrame Application Tab To Your Facebook Page. This will take you through adding an iFrame application tab to your Facebook page.
However replace the .html file with a .php file. Only the extension of the file name needs to change and not anything else within the example.
Step 2 – Insert Code into PHP file
Next you need to add this in the part of your PHP file you want to display a different message for non fans and fans.
$request = $_REQUEST["signed_request"];
list($encoded_sig, $load) = explode('.', $request, 2);
$fbData = json_decode(base64_decode(strtr($load, '-_', '+/')), true);
You are a fan – insert html here
You are not a fan – insert html here
Step 2 – Testing
To properly test your code:
- Go to your Fan Page and click the Unlike Button in the bottom left hand side of your page.
– You should now see the “Like” button at the top, meaning that you’re not yet a fan
– You should see the content of Non-Fan
– Click the “Like” button; you should then see the fans-only content and the non-fan content will go away