I created a Facebook App and I would like to check whether the current facebook user is fan or not of my facebook page (using Javascript). This verification must be done into the facebook app.
Best regards
I was trying the code:
function isEmptyObj(obj) {
for(var prop in obj) {
alert(prop);
if(obj.hasOwnProperty(prop))
return false;
}
return true;
}
window.fbAsyncInit = function() {
FB.init({
appId : 'APP_ID',
status : true,
cookie : true,
xfbml : true,
oauth : true,
});
var page_id = "PAGE_ID";
FB.api('/me/likes/' + page_id,function(response) {
if( response.data ) {
if( !isEmptyObj(response.data) )
alert('You are a fan!');
else
alert('Not a fan!');
} else {
alert('ERROR!');
}
});
}