<?php
$session = $facebook->getSession();
$user = $facebook->getUser();
$page = 'PAGEID';
// Session based API call.
if ($session) {
try {
$likeID = $facebook->api(array( 'method' => 'fql.query', 'query' =>
'SELECT target_id FROM connection WHERE source_id =' . $user . 'AND target_id =' .$page ));
if ( empty($likeID) ) {
// user has NOT Liked the page
echo "Like my page!";
} else {
// user HAS Liked the page
echo "Thank you for liking my page";
}
} catch (FacebookApiException $e) {
error_log($e);
}
}
?>