I would like to (in a non-intrusive way) to ask a visitor of our blog to like our facebook page. The problem is I don't want to show this message to everyone, just non-fans.
I've read through this post
How to check if a user likes my Facebook Page or URL using Facebook's API
and it appears that if you want to know if the user likes your facebook page, you need their permission.
My code is currently:
FB.api('/me/likes/--mypageid--',{limit: 1}, function(response) {
if( response.data ) {
if( !isEmpty(response.data) )
console.log('You are a fan!');
else
console.log('Not a fan!');
} else {
console.log(response);
}
});
Which always return an error: "An active access token must be used to query information about the current user."
I assume this is because I am not passing an access token, but to get this access token i have to ask the user for it, and I don't want any popups on my site.
Does anyone have any ideas how to accomplish this, I'm also open to any other suggestions on how to prompt users to like a page non-intrusively.
thanks!
Just want to update that this is not possible (as answered below) with the current FB api.