views:

1465

answers:

1

This is a noob question. According to Facebook API documentation, the sex field in Users.getInfo() function returns values based on users' locale. Hence, determine the gender of user is difficult.

Any solution suggested?

+4  A: 

1) This isn't an elegant solution, and perhaps there's a better way that uses the API, but what if you manually created a look-up table for different values of 'sex' in different locales? You could try checking out facebook profiles of people from different countries and get the string displayed for their sex. Then, put that into some kind of dictionary data structure that allows you to grab the M-F string pair based on the locale's code (also given by getInfo()). For example en-US => (male, female), ja-JP => (男性, 女性). Of course, you could try using google translate too. After you gathered this data for a handful of the main locales, you'd be more-or-less covered. Maybe someone on the internets already has done it.

Of course, you could try emailing someone who works on the API for these values. The list of locale codes is here http://wiki.developers.facebook.com/index.php/Facebook_Locales .

2) Here is probably a better solution than (1). If you directly query the FQL User table, the value returned in 'sex' will always be English, starting from February 7 2010. More information about that is here: http://wiki.developers.facebook.com/index.php/User_%28FQL%29 . So, perhaps in the future getInfo() will return only English too. Who knows.

3) The answer to your question is also given on this existing post: http://stackoverflow.com/questions/1594871/facebook-fql-user-table-sex-field-how-to-return-male-female-even-the-user-is

Benny Jobigan
very clear answer. thank you!
Shivan Raptor
the funny thing is that i've never touched, looked at, or even thought about the facebook api before in my life. search engines are pretty wonderful, huh? =)
Benny Jobigan

related questions