Jeff Voss
Jeff Voss

Reputation: 3695

Hide content from non-fans in a Facebook *IFrame*

There was a previous question asked about this but I have never found a solution, I am using the below code but it never, ever works:

<?php

$request = $_REQUEST["signed_request"];

list($encoded_sig, $load) = explode('.', $request, 2);

$fbData = json_decode(base64_decode(strtr($load, '-_', '+/')), true);

if (!empty($fbData["page"]["liked"]))

{ ?>

NON FAN STUFF

<?php } else { ?>

FAN STUFF

<?php } ?>

Upvotes: 1

Views: 1084

Answers (2)

ifaour
ifaour

Reputation: 38135

You are doing it the other way around!

It should be, if it's empty => not a fan
The way you are doing it now is: if it's NOT empty => not a fan!!

Please review my tutorial:

<?php
$signed_request = $_REQUEST["signed_request"];
list($encoded_sig, $payload) = explode('.', $signed_request, 2);
$data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);

if (empty($data["page"]["liked"])) {
    echo "You are not a fan!";
} else {
    echo "Welcome back fan!";
}
?>

Upvotes: 1

Kiran Gopakumar
Kiran Gopakumar

Reputation: 82

The code works for an app which is an iframe loaded in a Page tab.

Upvotes: 0

Related Questions