1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[GET] Reveal "like" iframe tutorial.

Discussion in 'FaceBook' started by fruity_looper, Jun 10, 2011.

  1. fruity_looper

    fruity_looper Junior Member

    Joined:
    Feb 19, 2010
    Messages:
    142
    Likes Received:
    72
    Occupation:
    Student
    Location:
    New Zealand
    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:

    __________________________________________________

    Next step is you will have to download and install the PHP SDK
    Click here to download it

    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!
     
    • Thanks Thanks x 38
    Last edited: Jun 10, 2011
  2. fruity_looper

    fruity_looper Junior Member

    Joined:
    Feb 19, 2010
    Messages:
    142
    Likes Received:
    72
    Occupation:
    Student
    Location:
    New Zealand
    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! :)
     
    • Thanks Thanks x 3
    Last edited: Jun 10, 2011
  3. m0nster

    m0nster Senior Member

    Joined:
    Oct 20, 2010
    Messages:
    1,044
    Likes Received:
    1,003
    Occupation:
    Offline Marketing
    Location:
    USA
    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 =]
     
  4. fruity_looper

    fruity_looper Junior Member

    Joined:
    Feb 19, 2010
    Messages:
    142
    Likes Received:
    72
    Occupation:
    Student
    Location:
    New Zealand
    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
     
  5. liskaa

    liskaa BANNED BANNED

    Joined:
    Aug 15, 2009
    Messages:
    129
    Likes Received:
    6
    can i see demo of this? What this script do ?
     
  6. fruity_looper

    fruity_looper Junior Member

    Joined:
    Feb 19, 2010
    Messages:
    142
    Likes Received:
    72
    Occupation:
    Student
    Location:
    New Zealand
    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 Thanks x 1
  7. moneyrocks

    moneyrocks Supreme Member

    Joined:
    May 22, 2009
    Messages:
    1,205
    Likes Received:
    135
    thanks man will be help full at some point thanks a lot
     
  8. rockyonfire

    rockyonfire Regular Member

    Joined:
    Apr 12, 2010
    Messages:
    248
    Likes Received:
    57
    Thank you very much for sharing this.
     
  9. viralfree1

    viralfree1 Newbie

    Joined:
    Mar 21, 2011
    Messages:
    38
    Likes Received:
    3
    anyone worked on it and got installed correctly ... i wana see demo link urgently
     
  10. BrianGriffen

    BrianGriffen Registered Member

    Joined:
    Mar 9, 2011
    Messages:
    78
    Likes Received:
    49
    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.
     
  11. xxMP3xx

    xxMP3xx Regular Member

    Joined:
    May 19, 2009
    Messages:
    368
    Likes Received:
    46
    Location:
    <?php return 'CPU'; ?>
    Seeing your few replies on some of the threads, it seems you are in greatest hurry.

    Be in queue. :D
     
  12. webworld99

    webworld99 Junior Member

    Joined:
    Sep 6, 2009
    Messages:
    101
    Likes Received:
    16
    tHANKS FOR THE SHARE. i was looking for something like this. rep +1
     
  13. JJayUrban

    JJayUrban Regular Member

    Joined:
    Apr 21, 2011
    Messages:
    365
    Likes Received:
    77
    Occupation:
    Website Development, IM
    Location:
    World Citizen
    Home Page:
    thanks for the share it is working fine on my Fan page ...:)
     
    • Thanks Thanks x 1
  14. thedudelady

    thedudelady Registered Member

    Joined:
    Jan 15, 2010
    Messages:
    93
    Likes Received:
    90
    just do it yourself as it is easy
     
  15. suicyco

    suicyco Registered Member

    Joined:
    Sep 13, 2009
    Messages:
    57
    Likes Received:
    7
    Location:
    as above so bellow
    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;
     
  16. fisko19

    fisko19 Registered Member

    Joined:
    Apr 10, 2010
    Messages:
    76
    Likes Received:
    4
    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: Jun 12, 2011
  17. fruity_looper

    fruity_looper Junior Member

    Joined:
    Feb 19, 2010
    Messages:
    142
    Likes Received:
    72
    Occupation:
    Student
    Location:
    New Zealand

    000webhost.com is one I've used from the many free webhosts avalible :)
     
    Last edited: Jun 12, 2011
  18. JJayUrban

    JJayUrban Regular Member

    Joined:
    Apr 21, 2011
    Messages:
    365
    Likes Received:
    77
    Occupation:
    Website Development, IM
    Location:
    World Citizen
    Home Page:
    You are not asking too much bro:p, Just Google it ;)


     
  19. todor

    todor Regular Member

    Joined:
    Feb 7, 2011
    Messages:
    394
    Likes Received:
    218
    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!
     
  20. JB2003

    JB2003 Registered Member

    Joined:
    Mar 16, 2010
    Messages:
    99
    Likes Received:
    13
    Thanks for the share!