How to Show Content only at your facebook page’s fans
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
}
?>
Have you a Fan page with reserved content? Let me know with a comment









I don’t know php but I replaced “…’appId’–> ‘APP ID HERE’ …” with “…’appId’=> ‘APP ID HERE’ …” because I got an error message.
Anyway, it seems still not working, cause I don’t get anything
http://www.facebook.com/Volia1euro?sk=app_182706635113910
Where you replace that code? You must add only your app id not entire url
I only replaced the ‘–>’ with ‘=>’ and then of course i put the app id and the secret key
When i try the code it works, but maybe something change in the Facebook code, let me see if that code works on my pages
I followed the guide but I did not get a positive result. Seems to work. To you working?
Did you followed tutorial step by step? Before publishing i testo what i share and i haven’t any kind of problem! However tomorrow i’ll test the code again
I inserted the code in file.php segunte but the result is a blank page. Am I wrong?
‘mynumber’,
‘secret’ => ‘mynumber’,
‘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']) {
Testo di Prova
} else {
// Non facebook fan Content
}
?>
This could have been GREAT but coudn´t get it running untill I looked somewhere else that i had to install facebook´s SDK aswell… anyway thx!
Thank you for your comment
IS there any way to create it in such a way that i can place a one time download button ?