Facebook – Like to see the content

Sometime in Facebook Pages, you can see the message / banner, we have offers for you, like us to see. Or Like us to unlock the content etc. These all are for getting more likes in their Facebook page and indeed, it is a very nice idea to spread your updates among many of your Facebook Fans. Usually people won’t do the dislike option to revert it back!

The question is how can we do this ?

The trick here is, you need to create a page using iframe as you usually create FB app. In that iframe, you have your custom page fragment hosted somewhere else showing some copies/contents/offer etc.

Each time when Facebook load your url inside the iframe, Facebook do a POST to your domain signed_request as the parameter. The rest of the part you have to handle with your server side scripting.

Here mine is PHP:

<?php

$signed_request = $_REQUEST["signed_request"];
// $_POST also work, but better with $_REQUEST

list($encoded_sig, $payload) = explode(‘.’, $signed_request, 2);

$data = json_decode(base64_decode(strtr($payload, ‘-_’, ‘+/’)), true);

if (empty($data["page"]["liked"])) {

//write code here to show a non-liked situational contents
echo “You haven’t liked us yet”;

}
else {

//write code here to show contents for already liked people
echo “Hello Fan, here are your offers.”;

}
?>

6 Comments

6 Responses to “Facebook – Like to see the content”

  1. TheAnand November 10, 2011 at 4:23 pm #

    I was wondering if it is possible to simulate a click when a visitor visits our website. I am looking to create a automated way by which a persons fb account can be used to like a post/website on fb when he visits the page without any action from his part. I am not looking for a code example, but wanted to know if this is technically possible.

    Thanks in advance!

    • Mr Me November 12, 2011 at 11:54 pm #

      It is not at all possible to simulate a click. If so, people would have made thousands of click on google ads on each visit and get that much of revenue.

      • TheAnand November 14, 2011 at 1:42 am #

        I know its not possible to simulate a client, I was looking to disguise a link. Found what I was looking for, will email you what I actually meant.

  2. Dana February 13, 2012 at 4:26 pm #

    Hello…I am confusing with this part…where should I put this code? in my index.php iframe application?

    • Mr Me February 15, 2012 at 12:41 pm #

      Anywhere you wish to use this like logic.

Trackbacks/Pingbacks

  1. Pass parameter to an iframe embedded Fan Page in Facebook | Programming Ideas, Logics, Tips and Tricks - January 5, 2012

    [...] my article here  to see how you can get the ‘like’ status using [...]

Leave a Reply

More in general, php source code (5 of 64 articles)


I tried new Adobe Edge yesterday, wow it is cool and it took only 10 minutes for me to develop ...