Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can do it in JavaScript like so (Building off of <a href="https://stackoverflow.com/questions/6246449/facebook-how-to-check-if-user-has-liked-page-and-show-content/6314568#6314568">@dwarfy's response to a similar question</a>):</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"&gt;&lt;/script&gt; &lt;style type="text/css"&gt; div#container_notlike, div#container_like { display: none; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="fb-root"&gt;&lt;/div&gt; &lt;script&gt; window.fbAsyncInit = function() { FB.init({ appId : 'YOUR_APP_ID', // App ID channelUrl : 'http(s)://YOUR_APP_DOMAIN/channel.html', // Channel File status : true, // check login status cookie : true, // enable cookies to allow the server to access the session xfbml : true // parse XFBML }); FB.getLoginStatus(function(response) { var page_id = "YOUR_PAGE_ID"; if (response &amp;&amp; response.authResponse) { var user_id = response.authResponse.userID; var fql_query = "SELECT uid FROM page_fan WHERE page_id = "+page_id+"and uid="+user_id; FB.Data.query(fql_query).wait(function(rows) { if (rows.length == 1 &amp;&amp; rows[0].uid == user_id) { console.log("LIKE"); $('#container_like').show(); } else { console.log("NO LIKEY"); $('#container_notlike').show(); } }); } else { FB.login(function(response) { if (response &amp;&amp; response.authResponse) { var user_id = response.authResponse.userID; var fql_query = "SELECT uid FROM page_fan WHERE page_id = "+page_id+"and uid="+user_id; FB.Data.query(fql_query).wait(function(rows) { if (rows.length == 1 &amp;&amp; rows[0].uid == user_id) { console.log("LIKE"); $('#container_like').show(); } else { console.log("NO LIKEY"); $('#container_notlike').show(); } }); } else { console.log("NO LIKEY"); $('#container_notlike').show(); } }, {scope: 'user_likes'}); } }); }; // Load the SDK Asynchronously (function(d){ var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;} js = d.createElement('script'); js.id = id; js.async = true; js.src = "//connect.facebook.net/en_US/all.js"; d.getElementsByTagName('head')[0].appendChild(js); }(document)); &lt;/script&gt; &lt;div id="container_notlike"&gt; YOU DON'T LIKE ME :( &lt;/div&gt; &lt;div id="container_like"&gt; YOU LIKE ME :) &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Where the channel.html file on your server just contains the line:</p> <pre><code> &lt;script src="//connect.facebook.net/en_US/all.js"&gt;&lt;/script&gt; </code></pre> <p>There is a little code duplication in there, but you get the idea. This will pop up a login dialog the first time the user visits the page (which isn't exactly ideal, but works). On subsequent visits nothing should pop up though.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload