Reputation: 467
I have a problem with getting the information if the user is a fan of a page (fanpage) becouse sometimes this query
SELECT uid FROM page_fan WHERE uid=$mUserId AND page_id=$iPageId
gets me an empty result although the user is a fan of the page
I used this JavaScript method which returned me "resp.error_code" and "resp.error_msg" was "Invalid API key"
FB.api({
method: 'pages.isFan',
page_id: 'FB_FAN_PAGE_ID',
uid: $iUser
}, function (resp) {
if (resp == true) {
alert('fan');
} else if (resp.error_code) {
alert(resp.error_msg);
} else {
alert('no-fan');
}
});
but the code is correct as the application starts and what is strange it sometimes works and sometimes doesn't work. I try to get the user is fan form request just like in this post How to check if a user likes my Facebook Page or URL using Facebook's API but it doesn't work. Help pleace
Upvotes: 1
Views: 391
Reputation: 853
With JS SDK you can check if the currently logged-in user has liked a page like this:
FB.api("me/likes/" + appPageId, function(response) {
if(response && response.data[0]) {
//user has liked the page
} else {
//user has not like the page
}
});
Upvotes: 2