Skip to content

Instantly share code, notes, and snippets.

@cdnsteve
Created December 6, 2012 16:59
Show Gist options
  • Save cdnsteve/4226038 to your computer and use it in GitHub Desktop.
Save cdnsteve/4226038 to your computer and use it in GitHub Desktop.
PHP: Facebook check if user likes page
<?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;
?>
<?php
//You can use $has_liked to wrap your fan-specific content
if($has_liked) : ?>
fan-specifc
<?php else : ?>
for non-fans only
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment