Created
December 6, 2012 16:59
-
-
Save cdnsteve/4226038 to your computer and use it in GitHub Desktop.
PHP: Facebook check if user likes page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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