Hide content from non-fans in a Facebook *IFrame* (Not FBML)
it is incredibly easy to hide content from someone who does not like your application...if you're using FBML. I'm using an iFrame and the JavaScript SDK, and am having terrible difficulty figuring this out.
The behavior I'm seei开发者_Go百科ng (both logged in and out) is that does not seem to be supported by FB.XFBML.parse(). Am I mistaken or is there an alternative method I can use that does not require the user to give explicit permission?
Finally figured it out!
After you have initialized the api (using FB.init()) simply do the following:
FB.api('/mypage', function (response) {
FB.api({ method: 'pages.isFan', page_id: response.id },
function (response) {
alert(response);
});
});
When the '/mypage' response comes back, it has the page id of the profile. Use that in the pages.isFan call and it will return a boolean object telling you if the current user has Liked that page or not.
No need to deal with authentication, extended permissions, or any FQL.
精彩评论