How to enable a facebook application only to invited friends?

Tag: facebook Author: wuweifeixain945 Date: 2009-08-21

I want to build a Facebook application that will be available only to those who have been invited to it or to a certain list of people (the list will be used for initialization).

How can I achieve that?

Best Answer

Depends what you mean by available. Anyone can install/authorise your application - all it means is that it'll appear in their applications list, and that your application has more access to their profile. However, whenever someone uses your application Facebook will send you their unique uid which you can then filter on within your own code. Store a list of uids that you consider "invited", and only allow them access. Probably the neatest way to do this is at the start of a session; the initial exchange between Facebook and your application involves Facebook sending your app a uid and authentication token, with which your app requests a session key - if you filter at that point and simply refuse to request a session key for any uid that's not on your list, you can programmatically restrict access.

comments:

I've hoped for a FB permission framework that will allow me to determine who can install my application (everyone, by network, only invited friends, etc...). You say it can only be done by the application itself (means that I've to implement it)?
All you can do via the API is restrict by demographic (e.g. by age or location) or ban specific users - you can't selectively allow users. So yes, you'll have to implement it yourself. --Edit-- The closest alternative is to set the application into Developer mode and list all your invited users as Developers; that way the app will be hidden from everyone else, but all your users will have Developer access.

Other Answer1

There is so called "application sandbox mode". It is intended for development and testing though. But the meaning of this mode - you directly specify what users have access to your app(testers)