Jorg Ancrath
Jorg Ancrath

Reputation: 1447

Total friend list count in Facebook Javascript SDK

Documentation for FQL seems to be lacking on the official website, here is a query I tried:

  FB.api("/fql?q=SELECT friend_count FROM user WHERE uid = me()", function(response) {
            $("#fbfriends_count").text(response);
        });

My #fbfriends_count prints out an [object Object], so I researched for a bit and found what my array looks like:

{
  "data": [
    {
      "friend_count": 152
    }
  ]
}

So now I tried:

 $("#fbfriends_count").text(response["data"]["friend_count"]);

But this returns me nothing, what am I doing wrong here?

Upvotes: 0

Views: 711

Answers (1)

Sagish
Sagish

Reputation: 1065

"data" is an array, use response["data"][0]["friend_count"] or response.data[0].friends_count

Upvotes: 2

Related Questions