How to check user like the facebook Application or not?

facebook, facebook-graph-api, facebook-like, facebook-page, php

Solution

<?php 
$user = $facebook->getUser(); 
if ($user) { 

try{ 
$user_profile = $facebook->api('/me');
 $likeID = $facebook->api(array( 'method' => 'fql.query',
 'query' => 'SELECT url FROM url_like WHERE user_id = "'.$user_profile['id'].'" AND url="myurl/"'; )); 
}
 catch(FacebookApiException $e) { }
 } 
if(count($likeID)>0) echo "User likes this page"; 
else echo "User doesn\'t like this page";

?>

credible and/or official sources:

- http://www.zuberi.me/2011/how-to-check-if-user-liked-the-application-or-page.html

- http://www.chilipepperdesign.com/2011/02/15/reveal-fan-gate-like-gate-facebook-iframe-tab-tutorial-with-php

- How to check if a user likes my Facebook Page or URL using Facebook's API

- Facebook how to check if user has liked page and show content?

- Facebook Check if user "Liked" the page

Problem

How can we check user liked the facebook application or not? I am trying to create a Facebook app, in it there are two different pages , if user liked then page_1 will be show, otherwise page_2 show.

Original source

Related problems