I created a little application in Facebook.
But the script that may proceed to check if People LIKE or not the page is not working ...
I have a section just for fans and another one just for non fans ... So when I click on the LIKE button, I assume it would put into the FAN part .. but it doesnt ...
Please see the code :
require 'src/facebook.php';
$app_id = "appID";
$app_secret = "appSecret";
$loginNextPage = 'http://www.facebook.com/BenefitCosmeticsFrance'.'?sk=app_'.$app_id;
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true
));
$signed_request = $facebook->getSignedRequest();
$like_status = $signed_request["page"]["liked"];
if ($like_status) {
// FOR FANS
$session = $facebook->getSession();
$loginUrl = $facebook->getLoginUrl(
array(
'canvas' => 1,
'fbconnect' => 0,
'next' => $loginNextPage
/*'req_perms' => 'publish_stream,photo_upload,user_photos,user_photo_video_tags' */
)
);
$fbme = null;
if (!$session) {
echo "<script type='text/javascript'>top.location.href = ".$loginUrl."; </script>";
exit;
}
else {
try {
$access_token = $facebook->getAccessToken();
$vars = "access_token=$access_token&pathToServer=$pathToServer&appName=$appName";
} catch (FacebookApiException $e) {
echo "<script type='text/javascript'>top.location.href = ".$loginUrl.";</script>";
exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
</head>
<body>
<h1>You Liked The Page</h1>
<iframe src="//www.facebook.com/plugins/like.php? href=http%3A%2F%2Fwww.facebook.com%2FBenefitCosmeticsFrance&send=false&layout=standard&width=150&show_faces=false&action=like&colorscheme=light&font&height=35&appId=112625882216036" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:150px; height:35px;" allowTransparency="true"></iframe>
</body>
</html>
<?php
}
}
else {
// FOR NON FANS
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
</head>
<body>
<h1>You Don't Like the Page</h1>
<iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.facebook.com%2FBenefitCosmeticsFrance&send=false&layout=standard&width=150&show_faces=false&action=like&colorscheme=light&font&height=35&appId=112625882216036" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:150px; height:35px;" allowTransparency="true"></iframe>
</body>
</html>
<?php
}
?>