views:

61

answers:

3

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 seeing (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?

A: 

Pseudocode (if used on client side (JavaScript) - unsecure but ok for 95% of users, server site (PHP, Python etc.) - secure):

MY_FANPAGE = 12345
likes = facebook.get_connections('me', 'likes')
if MY_FANPAGE [is in] likes:
    // show the content
else:
    // don't show the content
Tomasz Wysocki
I'm not sure it's possible to do that without requiring the user to log in.
Dusda
Found a much more direct, clean way to do this above. Thanks, though.
Dusda
+1  A: 

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.

Dusda
A: 

Dusda: Whhat does /mypage means? Can I ask for a specific page?

fedes
It refers to any page in your application. In the Facebook Application sense, it was something like apps.facebook.com/myapplication/mypage.
Dusda

related questions