Description:

This is not a full wordpress oriented post, but as you probably know FBLM is deprecated, so according to facebook dev guide, and Bigthink.it i’ll try to show you how to show a “secret” content only at your facebook page’s fans.

You must use a php language to do this, but remember you can user your favorite language to show content.

The Code:

Setup New Facebook Application:

  • Create new application Following this link
  • Follow the 2 step creation
  • Go to website and in “Site Url” field insert your website url (and remember the final slash ex- http://www.wpcode.net/)

  • Clicks on “Facebook Integration” and fill the “Canvas URL” field with the same url (remember the final slash)

  • In the Tab Space fill the “Tab Name Field” and “Tab Url” field

 

  • Then Click on “Save Changes”
  • In the Riepilogative Window click on “Application Profile Page”

  • Choose your page, then click on the Right “Add To Page”.

  • Go to choosen page/s and Clicks on  “Edit”
  • In the “Default Landing Tab” choose your added Tab

Setup the tab to show coupon at your fans only:

  • Download Facebook.php
  • Create a php file with the name you set into the “Tab URL” in my case “wpc_tab.php” and upload in in the position setted in the application
  • Upload in the same position the “Facebook.php” file downloaded
  • Add to your new file the following code
  • <!--p  require 'facebook.php'; $facebook = new Facebook(array( 'appId'--> 'APP ID HERE',
    'secret' => 'SECRET KEY HERE',
    'cookie' => true,
    ));
    
    $facebook = new Facebook(array('appId' => $app_id, 'secret' => $app_secret, 'cookie' => true, ));
    
    if (isset($_REQUEST['signed_request'])) {
    $encoded_sig = null;
    $payload = null;
    list($encoded_sig, $payload) = explode('.', $_REQUEST['signed_request'], 2);
    $sig = base64_decode(strtr($encoded_sig, '-_', '+/'));
    $signed_request = json_decode(base64_decode(strtr($payload, '-_', '+/'), true),true);
    }else {echo "ERROR";}
    
    if ($signed_request['page']['liked']) {
    // Facebook fan Content
    } else {
    // Non facebook fan Content
    }
    ?>
    
  • See the Live Demo

Have you a Fan page with reserved content? Let me know with a comment