views:

598

answers:

3

I am trying to determine if a user is a facebook fan. I load the facebook JS library and initialize:

<script type="text/javascript" src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/en_US"&gt;&lt;/script&gt;

FB_RequireFeatures(["XFBML","Connect","Api"], function() { FB.init("my_api_key","xd_receiver.htm") });

FB.ensureInit(function () {     
        FB.ApiClient.pages_isFan(my_profile_id,"some_UID",callback);
    });

However when I call the API client with FB.ApiClient.pages_isFan, I get a JS error -

FB.ApiClient is undefined

I am also using the FBML fan tag to display the "become a fan" button:

<fb:fan profile_id="my_profile_id" stream="0" connections="10" logobar="1" width="300"></fb:fan>

And would like to be notified when either the "become a fan" button is clicked or a user has successfully become a fan.

The business logic is pretty simple - If they become a fan, track it in my database. Then if they try to become a fan again, check with the library if they are a fan and say "You are already a fan" if they are a fan, show the widget if not.

A: 

Did you ever get an answer to this question?

Dhaval
A: 

Hi guys,

not sure if this is helpful at all, but I inspected the DOM with firebug and I found that it has moved onto the Facebook object

var pageID = 'your page';
var uid = FB.Facebook.apiClient.get_session().uid;
FB.Facebook.apiClient.pages_isFan(pageID, uid, function(result){ alert("boo!");});
A: 

Using the new JS SDK:

<fb:login-button perms="user_likes">
  Grant Permissions to Allow access to Likes
</fb:login-button>

<button onclick="checkDoesLike()">Check if user Likes the Page</button>

<h1>Like this Application's Page</h1>
<fb:like-box profile-id="184484190795"></fb:like-box>

<script>
window.checkDoesLike = function() {
  FB.api({ method: 'pages.isFan', page_id: '184484190795' }, function(resp) {
    if (resp) {
      Log.info('You like the Application.');
    } else {
      Log.error("You don't like the Application.");
    }
  });
};
</script>

A working example: http://fbrell.com/fb.api/does-like

daaku

related questions