How can i check if the current facebook user like a facebook page?
I have this code,
require_once(\"/path/to/sdk/facebook.php\");
// Create our
You can use FQL
$isFan = $facebook->api(array(
"method" => "fql.query",
"query" => "SELECT uid FROM page_fan WHERE page_id = '<YOUR PAGE ID>' AND uid = '<UID>"
));
I don't know if you need to do this only using FQL, but there is another easier way:
require_once("/path/to/sdk/facebook.php");
// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
'appId' => 'APP_ID',
'secret' => 'APP_SECRET',
));
$signed_request = $facebook->getSignedRequest();
$like = $signed_request['page']['liked'];
$like will be empty or 1.
I like to check variables first, like this:
if(is_array($signed_request) && isset($signed_request['page']) {
if($signed_request['page']['liked']) {
// do whatever you want to do if the user likes the page
} else {
// do whatever you want to do if the user don't like the page yet
}
}