In my website, when the visitor visit my web, if they have not liked my facebook page yet, i want to show Iframe like box. I have seen many code in the web as well as in stackoverflow, but it seem doesn't work well. Here is my javascript code:
$(document).ready(function(){
FB.init({
appId : 'IDAPP',
status : true,
cookie : true,
xfbml : true
});
FB.getLoginStatus(function(response) {
if (response.status == 'connected') {
var user_id = response.authResponse.userID;
var page_id = "PAGE_ID";
var fql_query = "SELECT uid FROM page_fan WHERE page_id =" + page_id + " and uid =" + user_id;
var the_query = FB.Data.query(fql_query);
the_query.wait(function(rows) {
alert(rows);
if (rows.length == 1 && rows[0].uid == user_id) {
alert("like");
} else {
alert("not like");
}
});
} else if (response.status === 'not_authorized') {
alert("not authorized");
} else {
alert("not login");
}
});
});
Request with login or not login or not_authorize it work well, but when check for page is like or note, it doesn't run anything.