user1022745
user1022745

Reputation: 31

How to create Facebook page with like button, if user like the page I will show him the content

I need to create Page with like button, if the user click on the like button I will show him the page content else he will still see the landing page until he click like?

Thanks for help.

Regards,

Eco

Upvotes: 0

Views: 377

Answers (1)

Marco Caltagirone
Marco Caltagirone

Reputation: 1206

In PHP you can use

<?php
$signed_request = $_REQUEST["signed_request"];

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

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

$app_data = isset($data["app_data"]) ? $data["app_data"] : '';
$_REQUEST["fb_page_id"] = $data["page"]["id"];
$access_admin = $data["page"]["admin"] == 1;
$has_liked = $data["page"]["liked"] == 1;
?>

and you can check if like using $has_liked

<?php if($has_liked) : ?>
fan-specifc
<?php else : ?>
for non-fans only
<?php endif; ?>

Upvotes: 1

Related Questions