[GET] Reveal "like" iframe tutorial.

fruity_looper

Junior Member
Joined
Feb 19, 2010
Messages
143
Reaction score
73
I've seen a few threads asking for this and promised I'd share it! :D

As most of you know FBML is being deprecated, so this code no longer works.

Code:
Non-fan content (eg. Like this page to see a monkey fly
<fb:visible-to-connection>
Fan content (eg. a flying monkey)
</fb:visible-to-connection>
__________________________________________________

Here's what's needed:

  • A place to host files
  • A FB PVA so you can create applications
  • Time and willingness to read/follow these steps.

__________________________________________________
Step 1
Create a new application by going to:
Code:
http://www.facebook.com/developers/
Click Set Up New App

Enter a name for the application
Click Agree to the TOS
Click Create Application

Enter the Captcha

You will be leaded to you application setup page
Click the Facebook Intergration tab
Give a Canvas Page name (custom URL for your app)


Give a You are going to need to make a folder on your site for your
Canvas URL (eg. http://www.test.com/iframe/ ) and then put that in as your Canvas URL

Change the iframe size to Auto-Resize (i just do that, up to you though)


Go down to the Page Tabs area:
Insert a Tab Name (eg. Welcome!)
For your Tab URL put the exact same link as you did for the Canvas URL

Save it so far.
__________________________________________________

Step 2
The code and setup

First step is to create a folder (eg. I called mine iframe)
Inside that folder create a php file, we'll call it index.php

Copy/Paste this code into index.php
Code:
<?php

include_once('fb_init.php');

// create the Facebook Graph SDK object
require_once('facebook.php');
$facebook = new Facebook(array(
    'appId'=>'[B]ENTER YOU APP ID HERE[/B]', // replace with your value
    'secret'=>'[B]ENTER YOUR APP SECRET HERE[/B]' // replace with your value
        ));
$signedRequest = $facebook->getSignedRequest();

// Inspect the signed request
if($signedRequest['page']['liked'] == 1){

    // Show the content for the person who liked the page
    print '<script type="text/javascript">
<!--
window.location = "[B]http://www.test.com/iframe/next.html[/B]"
//-->
</script>';

} else {

    // Show the reveal ask content
    print '<script type="text/javascript">
 <!--
 window.location = "[B]http://www.test.com/iframe/landing.html[/B]"
 //-->
 </script>';

}
?>
NOTES:

  • Please enter your App ID and App Secret into this code where stated.
  • Please change the http://www.test.com/iframe/next.html to your website and create a html , call it next.html
  • Please change the http://www.test.com/iframe/landing.html to your website and create a html , call it landing.html
__________________________________________________

Next step is you will have to download and install the PHP SDK
https://github.com/facebook/php-sdk/zipball/v3.0.1

Extract all the files:

What we want from this is EVERYTHING in the src folder
Put the files from the src folder into your iframe folder online

That means:
base_facebook.php
fb_ca_chain_bundle.crt
facebook.php

all in /iframe

(DON'T do this /iframe/src please, it won't work)

__________________________________________________

Inside the folder iframe create a php file, called fb_init.php

Copy/Paste this code into fb_init.php
Code:
<?php
     // depending on your hosting provider, you may need to include
     // the entire path to the directory you added this file to, for example
     // if your FTP login is, '[B]monkey[/B]', it may be, consult your ISP's docs
     // for additional assistance:
     // require_once('/home/monkey/public_html/iframe/facebook.php');
     require_once('facebook.php');
     $facebook = new Facebook(array(
          'appId'=>'',     // from Facebook
          'secret'=>'',     // from Facebook
          'cookie'=>true
     ));
?>
Change
/home/monkey/public_html/iframe/facebook.php
to your directory.

Mine was shorter like
monkey/public_html/iframe/facebook.php


After that's done. You've setup the code!!! YAY!!! :D
__________________________________________________

Step 3

Setup landing.html and next.html with the things you want to show!

landing.html is the content for the person who has NOT liked the page yet

next.html is the content for the person who liked the page

__________________________________________________


I Hope this has helped people!
If there is anything wrong please tell me by POSTING HERE

If it was of use feel free to thank me and/or give me some rep :D

Enjoy!
 
Last edited:
NEARLY FORGOT THIS!!!

Adding your application to your fanpage

Go to your the developers page http://facebook.com/developers

Click on your app

Click on Application Profile Page

When you're on the page of you application
Click Add to my Page


Done! :)
 
Last edited:
apparently you rock and I've repped you recently and can't again lol. keep up the good shares. I needed this badly and now i don't have to search. thanks again =]
 
apparently you rock and I've repped you recently and can't again lol. keep up the good shares. I needed this badly and now i don't have to search. thanks again =]

So everything is working fine I assume?
I wrote this as best as I could, I was thinking I might have forgetten something...

Guess I haven't then?

:D
 
can i see demo of this? What this script do ?

It hides content from users who have not liked your page and reveals it when a user has liked you page.

I will setup a demo for you soon :)
 
thanks man will be help full at some point thanks a lot
 
anyone worked on it and got installed correctly ... i wana see demo link urgently
 
Do you (or anyone) have this working on a site that we can demo.
Not because I don't think it's working, just so I can see it.
 
tHANKS FOR THE SHARE. i was looking for something like this. rep +1
 
are this like, share gateway ok regarding fb tos? if they are this is definetly a monster viral opportunity for all kind of services, businesses to offer, just use imagination, thnx;
 
That's nice! Thanks for the info.

Does anyone know where we can host files for free? That they remain safe, secure, and available online 99.9% of the time ? (in another words, have 99% uptime).
I don't need to host GBs of data, I need to host html files of my Welcome tab of my page.

Thanks! :)
 
Last edited:
That's nice! Thanks for the info.

Does anyone know where we can host files for free? That they remain safe, secure, and available online 99.9% of the time ? (in another words, 99% uptime).

Thanks! :)


000webhost.com is one I've used from the many free webhosts avalible :)
 
Last edited:
You are not asking too much bro:P, Just Google it ;)


That's nice! Thanks for the info.

Does anyone know where we can host files for free? That they remain safe, secure, and available online 99.9% of the time ? (in another words, 99% uptime).

Thanks! :)
 
Good opportunity, though I suppose we can't use this setup for CPA? :P (sorry for asking if it's stupid, but I don't have experience with FB).

Thanks, mate!
 
Back
Top