开发者

Getting a friend count from Facebook (possibly using api)

I'm used to working with Twitter, where friend/follower totals are available in a simple XML request.

My goal is a simple "enter your username/user id, and display your friends count".

Is there something like this for Facebook? From what I gather, I'll have to make an appl开发者_运维技巧ication, and have anyone who wants to grab their friends total actually install that app from within their own Facebook profile.

Anyone have any experience with this?


You can get friend count by fql easily.

There is a friend_count field against the user table that you can query.

SELECT friend_count FROM user WHERE uid = me();

https://graph.facebook.com/fql?q=SELECT friend_count FROM user WHERE uid={any id}


You do need to set up an application, but it'll work as a Connect app - meaning that users won't have to access it through their Facebook profile at all. In broad terms you'll need to:

  1. Set up an application
  2. Implement Facebook Connect on your site
  3. Get users of your site to log in with Connect. (You can't ask for their username/password.)
  4. Make a Friends.get call to the API, probably with the JavaScript client library (although there are server-side ways you can do it)


Facebook provides an API for developers so you can grab information from Facebook. Check it out at the provided link.

Edit: From your tags, it looks like you are already familiar with the Facebook API. You can use the API with external applications or webpages - it doesn't necessarily need to be used within a Facebook app, if that is what you are asking.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜