Return to Snippet

Revision: 46860
at May 26, 2011 22:58 by erikportin


Initial Code
<?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);
  }
}
?>

Initial URL

                                

Initial Description

                                

Initial Title
Check if user liked page | PHP | Facebook

Initial Tags
php, facebook

Initial Language
PHP